Handle exact filtered includes without giving an error
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
****
I have 2 functions like below:
```
public static IQueryable GetAcessibleContactsQueryable(this IQueryable queryable, long for_user_id)
{
queryable = queryable
.Include(x => x.Groups).ThenInclude(x => x.Group).ThenInclude(x => x.GroupUsers.Where(x => x.user_id == for_user_id))
//....
//Some other filters
//....
return queryable;
}
public static IQueryable GetIncludeQueryableForContactBase(this IQueryable queryable, long? for_user_id = null)
{
//We are including GroupUsers to fetch current user's permission with respect to this contact
queryable = queryable
.Include(x => x.Groups).ThenInclude(x => x.Group).ThenInclude(x => x.GroupUsers.Where(x => x.user_id == for_user_id))
.Include(x => x.Emails)
.Include(x => x.Phones);
return queryable;
}
```
When we execute `GetAcessibleContactsQueryable` and `GetIncludeQueryableForContactBase` we get an error saying we can't apply `.Where(x=> x.user_id == for_user_id)` more than once within a filtered include.
**Ideally**
EF Core should not give out an error if `for_user_id` is same for both the filtered includes. As the end result is a single filtered .Includes
Contributor guide
Assessment
This issue has not been assessed yet.