Skip to content

Instantly share code, notes, and snippets.

@danielmackay
Created December 5, 2014 01:14
Show Gist options
  • Select an option

  • Save danielmackay/ec251db1d2049b3dadee to your computer and use it in GitHub Desktop.

Select an option

Save danielmackay/ec251db1d2049b3dadee to your computer and use it in GitHub Desktop.
Type safe extension method that allows you to pass a list of expressions to determine navigation properties for EF to load. #ef
internal static class QueryableExt
{
public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query, params Expression<Func<T, object>>[] includes) where T : class
{
if (includes == null)
return query;
foreach (var include in includes)
{
query = query.Include(include);
}
return query;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment