NOTE: This is an entire rewrite of the previous question.
I have a model.
class Paragraph
{
public int Id { get; set; }
public int SectionId { get; set; }
public virtual Section Section { get; set; }
public int Major { get; set; }
public int Option { get; set; }
public ICollection<Paragraph> Options
{
get
{
// What I'm trying to return is:
//
// Section.Paragraphs
// .Where(p => p.Major == Major && p.Option != Option)
// .ToList()
}
}
}
It is involved in a one to many relationship; where each Section has many Paragraphs. What I’m trying to return is a list of paragraphs where their Major is the same as the entity’s Major and the Option isn’t the same. Basically.
Where(p => p.Major == Major && p.Option != Option)
Any advice on how to accomplish this? Thank you.
I solved it. Woop-woop! All I did was check if
Sectionwas null, and if it was I returned a blankList<Paragraph>. SoOptionsbecomes.