public static IEnumerable <SelectListItem> SelectListFromEntities <T>(GrowDbContext context) where T : BaseTimestampedEntity { var files = context .Set <T>() .OrderBy(e => e.Name); return(SelectListFromEntityList(files)); }
public static IEnumerable <SelectListItem> SelectListFromEntities <T>(GrowDbContext context, int currentContestId) where T : BaseContestSubEntity { var files = context .Set <T>() .Where(e => e.ContestId == currentContestId) .OrderBy(e => e.Name); return(SelectListFromEntityList(files)); }
public static IEnumerable <SelectListItem> SelectListFromFiles <TSource>(GrowDbContext context, Expression <Func <TSource, File> > propertyLambda) where TSource : BaseEntity { var fileCategory = GetFileCategoryForProperty(propertyLambda); var files = context .Set <File>() .Where(e => (e.Category ?? "misc").Equals(fileCategory.ToString(), StringComparison.CurrentCultureIgnoreCase)) .OrderBy(e => e.Name); return(SelectListFromEntityList(files)); }
private static IEnumerable <FileUsage> FindFileReferences <TEntity, TProperty>(Func <TEntity, TProperty> propertyExpression, TProperty referenceValue, GrowDbContext context) where TEntity : BaseEntity { return(context .Set <TEntity>() .Where(e => referenceValue.Equals(propertyExpression(e))) .Select(e => new FileUsage() { ReferrerId = e.Id, ReferrerName = (e is BaseNamedEntity ? (e as BaseNamedEntity).Name : e.Id.ToString()), ReferrerType = typeof(TEntity).Name } )); }