コード例 #1
0
        public static IEnumerable <SelectListItem> SelectListFromEntities <T>(GrowDbContext context) where T : BaseTimestampedEntity
        {
            var files = context
                        .Set <T>()
                        .OrderBy(e => e.Name);

            return(SelectListFromEntityList(files));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
 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
     }
                    ));
 }