I have a self-referencing entity:
When I query this entity..
var query = this._context.DispositionPossibilities
.Where(x => x.AreaID == areaID)
.Where(x => x.IsActive == true);
.. the resulting collection has EVERY item returned from the query at the root, and then the those items with ParentIDs are 'duplicated' inside the child collections (because of Navigation Properties).
I can remove them by doing this:
// have to ToArray() first because the child entities will be excluded if I don't..
rValue = query.ToArray();
// trim off the entities at the root that shouldn't be there..
rValue = rValue.Where(x => !x.ParentCode.HasValue).ToArray();
.. But is there a better way to do this?