Пример #1
0
Файл: DB.cs Проект: liaoyu45/LY
 public void Save(Dictionary <object, string> data)
 {
     Exec(d => {
         var aaa = new Dictionary <object, object>();
         foreach (var item in data)
         {
             var type = DbSets.FirstOrDefault(e => e.Name == item.Value);
             if (type != null)
             {
                 var newModel = Activator.CreateInstance(type);
                 Gods.Him.CopyTo(item.Key, newModel);
                 d.Set(type).Add(newModel);
                 aaa[item.Key] = newModel;
             }
             else
             {
                 d.Set(item.Key.GetType()).Add(item.Key);
             }
         }
         d.SaveChanges();
         foreach (var item in aaa)
         {
             Gods.Him.CopyTo(item.Value, item.Key);
         }
     });
 }
Пример #2
0
 public IDbSet <T> GetDbSet <T>() where T : class
 {
     return((IDbSet <T>)DbSets.FirstOrDefault(db => db.GetType().GetInterfaces().Contains(typeof(IDbSet <T>))));
 }