Пример #1
0
 public List <T> Query <T>(string sql, params object[] parameterValues)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         return(ct.ExecuteQuery <T>(sql, parameterValues).ToList());
     }
 }
Пример #2
0
 /// <summary>
 /// 排序
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="IsUp"></param>
 public void Sort(int ID, bool IsUp)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         var md = ct.DS_Area.Single(a => a.ID == ID);
         ct.ExecuteCommand("update DS_Area  set px=(select RowNumber from (select (ROW_NUMBER() OVER (ORDER BY px)) AS RowNumber,id from DS_Area where  ParentID={0}) as p2 where id=DS_Area.id) where ParentID={0}", md.ParentID);
         if (IsUp)
         {
             DS_Area p = ct.DS_Area.Single(a => a.ID == ID);
             DS_Area p1;
             if (p.Px > 1)
             {
                 p1 = ct.DS_Area.Single(a => a.Px == (p.Px - 1) && a.ParentID == md.ParentID);
                 p.Px--;
                 p1.Px++;
             }
         }
         else
         {
             DS_Area p = ct.DS_Area.Single(a => a.ID == ID);
             DS_Area p1;
             if (p.Px < ct.DS_Area.Where(a => a.ParentID == md.ParentID).Count())
             {
                 p1 = ct.DS_Area.Single(a => a.Px == (p.Px + 1) && a.ParentID == md.ParentID);
                 p.Px++;
                 p1.Px--;
             }
         }
         ct.SubmitChanges();
     }
 }
Пример #3
0
 public DS_Area GetSingle(int ID)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         return(ct.DS_Area.Single(a => a.ID == ID));
     }
 }
Пример #4
0
 private void delSub(List <DS_Area> list)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Area.DeleteAllOnSubmit(list);
         ct.SubmitChanges();
     }
 }
Пример #5
0
 public void Update(DS_Area Area)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Area.Attach(Area, true);
         ct.SubmitChanges();
     }
 }
Пример #6
0
 public void Add(DS_Area Area)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Area.InsertOnSubmit(Area);
         ct.SubmitChanges();
     }
 }
Пример #7
0
 public List <DS_Area> Query(string condition, string orderby, params object[] param)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Area> AreaList = ct.DS_Area;
         if (!string.IsNullOrEmpty(condition))
         {
             AreaList = AreaList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             AreaList = AreaList.OrderBy(orderby);
         }
         return(AreaList.ToList());
     }
 }
Пример #8
0
 public List <DS_Area> Query(string condition, string orderby, int startIndex, int pageSize, ref int pageCount, params object[] param)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Area> AreaList = ct.DS_Area;
         if (!string.IsNullOrEmpty(condition))
         {
             AreaList = AreaList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             AreaList = AreaList.OrderBy(orderby);
         }
         pageCount = AreaList.Count();
         return(AreaList.Skip(startIndex).Take(pageSize).ToList());
     }
 }
Пример #9
0
 public void Delete(int ID)
 {
     using (var ct = new DS_AreaDataContext(DbHelperSQL.Connection))
     {
         var st   = ct.DS_Area.Single(a => a.ID == ID);
         var list = ct.DS_Area.Where(a => a.ParentID.Equals(st.ID));
         if (list.Count() > 0)
         {
             foreach (var item in list)
             {
                 Delete(item.ID);
             }
         }
         ct.DS_Area.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }