Example #1
0
 public List <T> Query <T>(string sql, params object[] parameterValues)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         return(ct.ExecuteQuery <T>(sql, parameterValues).ToList());
     }
 }
Example #2
0
 public DS_OrderDetail GetSingle(int ID)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         return(ct.DS_OrderDetail.Single(a => a.ID == ID));
     }
 }
Example #3
0
 public void Update(DS_OrderDetail OrderDetail)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         ct.DS_OrderDetail.Attach(OrderDetail, true);
         ct.SubmitChanges();
     }
 }
Example #4
0
 public void Add(DS_OrderDetail OrderDetail)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         ct.DS_OrderDetail.InsertOnSubmit(OrderDetail);
         ct.SubmitChanges();
     }
 }
Example #5
0
 public void Delete(int ID)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         DS_OrderDetail st = ct.DS_OrderDetail.Single(a => a.ID == ID);
         ct.DS_OrderDetail.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }
Example #6
0
 public List <DS_OrderDetail> Query(string condition, string orderby, params object[] param)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_OrderDetail> OrderDetailList = ct.DS_OrderDetail;
         if (!string.IsNullOrEmpty(condition))
         {
             OrderDetailList = OrderDetailList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             OrderDetailList = OrderDetailList.OrderBy(orderby);
         }
         return(OrderDetailList.ToList());
     }
 }
Example #7
0
 public List <DS_OrderDetail> Query(string condition, string orderby, int startIndex, int pageSize, ref int pageCount, params object[] param)
 {
     using (var ct = new DS_OrderDetailDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_OrderDetail> OrderDetailList = ct.DS_OrderDetail;
         if (!string.IsNullOrEmpty(condition))
         {
             OrderDetailList = OrderDetailList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             OrderDetailList = OrderDetailList.OrderBy(orderby);
         }
         pageCount = OrderDetailList.Count();
         return(OrderDetailList.Skip(startIndex).Take(pageSize).ToList());
     }
 }
Example #8
0
        public void Add(DS_Orders Order, List <DS_OrderDetail> OrderDetail)
        {
            using (var con = DbHelperSQL.GetConnection()) {
                var tran = con.BeginTransaction();
                var ct   = new DS_OrdersDataContext(con);
                ct.Transaction = tran;
                var ct2 = new DS_OrderDetailDataContext(con);
                ct2.Transaction = tran;
                ct.DS_Orders.InsertOnSubmit(Order);
                ct.SubmitChanges();
                foreach (var odd in OrderDetail)
                {
                    odd.OrderID = Order.ID;
                }
                ct2.DS_OrderDetail.InsertAllOnSubmit(OrderDetail);
                ct2.SubmitChanges();

                tran.Commit();
            }
        }