I was trying to solve a many to many relation. On a database level everthing looks good to me, but when I tryr to get that data(inlcude), it fails.
I get:
Lambda expression used inside Include is not valid.
What I call/tried:
var readRecipes = db.MyClasses.
Include(blog => blog.SomeCollections).ThenInclude(post => post.Prop1).
Include(blog => blog.SomeCollections).ThenInclude(post => post.Prop2).
Structure
MainClass:
public class MainClass{
// ...
public ICollection<NavigationProperty> NavigationPropertys;
// ...
public MainClass()
{
this.NavigationPropertys = new Collection<NavigationProperty>();
}
}
NavigationProperty:
public class NavigationProperty
{
public Guid ID { get; set; }
[Required]
public Guid? Prop1ID { get; set; }// 0,*
[Required]
public Guid? Prop2ID { get; set; }// 0,*
[Required]
public Guid MainClassID { get; set; }
[Required]
public Prop1 Prop1 { get; set; }
[Required]
public Prop2 Prop2 { get; set; }
public MainClass MainClass { get; set; }
[Required]
public float Amount { get; set; }
public NavigationProperty()
{
// todo: ?
}
}
I don't know, what I did wrong ?
Ok, I solved my question.
Instead of:
public ICollection<NavigationProperty> NavigationPropertys;
I should have used:
public ICollection<NavigationProperty> NavigationPropertys { get; set; };
This made Lambda crash.
Thank You.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With