using System.Linq; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore; namespace Content.Server.Database; internal static class EFCoreExtensions { extension(IQueryable query) where TEntity : class { public IQueryable ApplyIncludes( IEnumerable>> properties) { var q = query; foreach (var property in properties) { q = q.Include(property); } return q; } public IQueryable ApplyIncludes( IEnumerable>> properties, Expression> getDerived) where TDerived : class { var q = query; foreach (var property in properties) { q = q.Include(getDerived).ThenInclude(property); } return q; } } }