コード例 #1
0
 public void Insert(WmsContext db, UsersInfo obj, List <Permission> pList, List <ButtonPermission> btnList)
 {
     using (TransactionScope ts = new TransactionScope())
     {
         // 让使用typeof(T).Name标签的所有缓存过期
         QueryCacheManager.ExpireTag(nameof(UsersInfo));
         QueryCacheManager.ExpireTag(nameof(Permission));
         QueryCacheManager.ExpireTag(nameof(ButtonPermission));
         db.Configuration.ValidateOnSaveEnabled = false;
         BaseDAL baseDAL = DALFty.Create <BaseDAL>();
         db.Set <UsersInfo>().Add(obj);
         db.SaveChanges();
         if (pList.Count > 0)
         {
             baseDAL.AddByBulkCopy <Permission>(db, pList);
         }
         if (btnList.Count > 0)
         {
             baseDAL.AddByBulkCopy <ButtonPermission>(db, btnList);
         }
         db.Configuration.ValidateOnSaveEnabled = true;
         ts.Complete();
     }
 }
コード例 #2
0
 private void Save() => _context.SaveChanges();