I am having trouble returning a list by executing a SelectLINQ query . This is the request:
var data = Repository<EducationString>
.Find()
.ToList()
.Select(p => new EducationStringModel() {
Id = p.Id,
Title = p.Title,
EducationDegree=p.EducationDegree })
.ToList();
As you can see, I used ToList()2 times. I don’t know why, but when I delete the first one ToList(), I see this error, "The index was outside the array", but if there is ToList()no problem.
Would it help if I said what EducationDegreeto EducationStringModeleat IList<EducationDegree>?
Is there anyone who knows the reason?
@Mark: its L2O
if u need to see classes:
EducationStringModel
{
private IList _educationDegree = List();
IList EducationDegree { { if (_educationDegree == null) { _educationDegree = List(); } return _educationDegree; } set {_educationDegree = ; }
}
public int? Id { get; set; }
public string Title { get; set; }
}
EducationString {
_title; IList _educationExperiences; IList _educationDegree;
virtual public string Title
{
get { return _title; }
set { _title = value; }
}
virtual public IList<EducationExperience> EducationExperiences
{
get
{
if (_educationExperiences == null)
{
_educationExperiences = new List<EducationExperience>();
}
return _educationExperiences;
}
set
{
_educationExperiences = value;
}
}
virtual public IList<EducationDegree> EducationDegree
{
get
{
if (_educationDegree == null)
{
_educationDegree = new List<EducationDegree>();
}
return _educationDegree;
}
set
{
_educationDegree = value;
}
}
}