'Add one object in list nested entity in EF Core
I create a repository layer in my app. I don't need all list EntityList. I want add in Foo.EntityList 1 object which equals entityId, and return foo in notImportant. How can I do this?
I am using EF Core 3.1 - I can't use Where() in Include().
How can I realize this contruction in EF Core 3.1?
Foo.Include(c => c.Entity.Where(o => o.Id == entityId)).ThenInclude(o => o.EntityProperty)
I thought to do it with Join() but I don't know how.
This is the method in my repo:
Task<NotIpmortantEntity> FetchNotImportantEntity(int year, Guid foosId, Guid entityId);
{
var db = Datasource();
var foo = db.Foo.Where(/???/)
var notImportant = NotIpmortantEntity.New(year, Foo);
}
Foo has these properties:
Foo:
|--Guid FoosId
|--IList<Entity> EntityList
And Entity has these properties:
Entity:
|--Guid EntityId
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
