I am trying to do
IList<Sth> sths= Context.Sth.Where(g => g.IsX == true && g.Y.Name== "name").ToList(); //here it successfully compares g.Y.Name
foreach (Sth g in sths)
{
Context.Entry(g).Collection(g=>g.Y).Load(); //the exception is thrown here
this.mylist.Add(g.Y.Id);
}
I already tried
using System.Data.Entity;
using System.Linq;
.
g.Yis notICollection<>. Use either.Referencemethod (instead of.Collection) or better why not eager load it in the main query withInclude.Includelearn.microsoft.com/en-us/ef/ef6/querying/related-data