Ejemplo n.º 1
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="paraTb_Roletouser"></param>
 /// <returns>true:删除成功,false:不存在该记录</returns>
 public bool deleteMode(tb_RoleToUser paraTb_Roletouser)
 {
     if(paraTb_Roletouser == null)
         throw new ArgumentNullException("paraTb_Roletouser");
     try
     {
         var query = from p in _context.tb_RoleToUser
             where p.RoleUserId == paraTb_Roletouser.RoleUserId
             select p;
         if (query.ToList().Count<1)
         {
             return false;
         }
         else
         {
             foreach(var model in query.ToList())
             {
                 if(!_context.IsAttached(model))
                     _context.tb_RoleToUser.Attach(model);
                 _context.tb_RoleToUser.DeleteObject(model);
                 _context.SaveChanges();
             }
             return true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="paraTb_Roletouser"></param>
 /// <returns>true:插入成功,false:已存在该记录</returns>
 public bool addMode(tb_RoleToUser paraTb_Roletouser)
 {
     if(paraTb_Roletouser == null)
         throw new ArgumentNullException("paraTb_Roletouser");
     try
     {
         var query = from p in _context.tb_RoleToUser
             where p.RoleUserId == paraTb_Roletouser.RoleUserId
             select p;
         if (query.ToList().Count() > 0)
         {
             return false;
         }
         else
         {
             _context.tb_RoleToUser.AddObject(paraTb_Roletouser);
             _context.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 用于向 tb_RoleToUser EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddTotb_RoleToUser(tb_RoleToUser tb_RoleToUser)
 {
     base.AddObject("tb_RoleToUser", tb_RoleToUser);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="paraTb_Roletouser"></param>
 /// <returns>true:更新成功,false:更新数据失败,不存在该记录!</returns>
 public bool updateMode(tb_RoleToUser paraTb_Roletouser)
 {
     if(paraTb_Roletouser == null)
         throw new ArgumentNullException("paraTb_Roletouser");
     try
     {
         var oldEntity = (from p in _context.tb_RoleToUser
             where p.RoleUserId == paraTb_Roletouser.RoleUserId
             select p).FirstOrDefault();
         if (oldEntity == null)
         {
             return false;
         }
         else
         {
             _context.ApplyCurrentValues(oldEntity.GetType().Name, paraTb_Roletouser);
             _context.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 /// <summary>
 /// 创建新的 tb_RoleToUser 对象。
 /// </summary>
 /// <param name="roleUserId">RoleUserId 属性的初始值。</param>
 public static tb_RoleToUser Createtb_RoleToUser(global::System.Int32 roleUserId)
 {
     tb_RoleToUser tb_RoleToUser = new tb_RoleToUser();
     tb_RoleToUser.RoleUserId = roleUserId;
     return tb_RoleToUser;
 }