示例#1
0
 private static void AttachRussianEnums <TEnum>(DbSet <TEnum> dbSet) where TEnum : class, IRussianEnum
 {
     //todo: cache values to improve performance
     foreach (TEnum value in RussianEnumUtils.GetValues <TEnum>())
     {
         dbSet.Attach(value);
     }
 }
示例#2
0
        private static void PopulateRussianEnum <TEnum>(DbContext context, DbSet <TEnum> dbSet) where TEnum : class, IRussianEnum
        {
            var items = RussianEnumUtils.GetValues <TEnum>().ToArray();

            dbSet.AddOrUpdate(items);
            foreach (var obj in items)
            {
                if (context.Entry(obj).State == EntityState.Unchanged)
                {
                    context.Entry(obj).State = EntityState.Modified;
                }
            }
        }