I've a FilterAsync method to do the query with where clause and includes the navigation properties. Below is the method for the FilterAsync.
public async Task<IQueryable<T>> FilterAsync<T>(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes) where T : class
{
return await Task.Run(() =>
{
//Return first 250 records/objects from
var query = _context.Set<T>().Where(predicate).AsQueryable().Take(250);
return includes.Aggregate(query, (current, includeProperty)
=> current.Include(includeProperty).AsQueryable());
});
}
My Actual query that calls the filterasync method to get the required data is below.It has conditions for the where clause and the navigational properties as included.
model = await _repo.FilterAsync<SchoolContractServiceAreas>
(psa => psa.SchoolId == SchoolId &&
psa.SchoolContract.StartDate < DateTime.Now &&
psa.SchoolContract.EndDate > DateTime.Now,
pc=> pc.SchoolContract ,
p=> p.SchoolContract.School);
Now, the Question is - When I see the query that is being transformed in to SQL in SQL Profiler is, It is doing inner join with the SchoolContract and SchoolContractPartner. But, I want to do Right join on p=> p.SchoolContract.School. How can I implment a right join on this? Thanks for the help in advance.