Exemplo n.º 1
0
 public static void Update(string connectionString, T entity, T original)
 {
     using (MainDataContext db = new MainDataContext(connectionString))
     {
         try
         {
             db.GetTable <T>().Attach(entity, original);
             db.SubmitChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 2
0
 public static void Update(T entity)
 {
     using (MainDataContext db = new MainDataContext())
     {
         try
         {
             db.GetTable <T>().Attach(entity, true);
             db.SubmitChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 3
0
 public static void Insert(T entity)
 {
     using (MainDataContext db = new MainDataContext())
     {
         try
         {
             db.GetTable <T>().InsertOnSubmit(entity);
             db.SubmitChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 4
0
 public static void Delete(string connectionString, T entity)
 {
     using (MainDataContext db = new MainDataContext(connectionString))
     {
         try
         {
             db.GetTable <T>().Attach(entity, true);
             db.GetTable <T>().DeleteOnSubmit(entity);
             db.SubmitChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Exemplo n.º 5
0
        public static void Insert(string connectionString, List <T> entity)
        {
            using (MainDataContext db = new MainDataContext(connectionString))
            {
                try
                {
                    foreach (T obj in entity)
                    {
                        db.GetTable <T>().InsertOnSubmit(obj);
                    }

                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 6
0
        public static void Delete(List <T> entity)
        {
            using (MainDataContext db = new MainDataContext())
            {
                try
                {
                    foreach (T obj in entity)
                    {
                        db.GetTable <T>().Attach(obj, true);
                        db.GetTable <T>().DeleteOnSubmit(obj);
                    }

                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }