I am trying to create a multiple include method in my repository to use as follows:
repository.Include(x => x.Images, x => x.Tags).First(x
I guess the shortest way is as follows:
public static class LinqExtensions
{
///
/// Acts similar of .Include() LINQ method, but allows to include several object properties at once.
///
public static IQueryable IncludeMultiple(this IQueryable query, params Expression>[] paths)
where T : class
{
foreach (var path in paths)
query = query.Include(path);
return query;
}
}