I'm struggling with a db application, where I need to get the distinct values. The whole structure looks somewhat like this
class A
{
public virtual ICollection<B> Bs { get; set; }
}
class B
{
public virtual C C { get; set; }
}
class C
{
public int x {get; set;}
}
This is the model from a db and I have a subset of all A's
. Now I need to get all distinct
values C.x
from all those A's
.
So basically something like
db.A.Where(something).SelectMany(s => s.Bs.SelectMany(t => t.C.x).ToList().Distinct()).ToList()
But it tells me, that the second SelectMany
cannot be inferred from the usage.