Exemple #1
0
 public DS_Property GetSingle(int ID)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         return(ct.DS_Property.Single(a => a.ID == ID));
     }
 }
Exemple #2
0
 public List <T> Query <T>(string sql, params object[] parameterValues)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         return(ct.ExecuteQuery <T>(sql, parameterValues).ToList());//ct.DS_Property.Where(c=>System.Data.Linq.SqlClient.SqlMethods.Like(字段,"%A%"))
     }
 }
Exemple #3
0
 /// <summary>
 /// 排序
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="IsUp"></param>
 public void Sort(int ID, bool IsUp)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         var md = ct.DS_Property.Single(a => a.ID == ID);
         ct.ExecuteCommand("update DS_Property  set px=(select RowNumber from (select (ROW_NUMBER() OVER (ORDER BY px)) AS RowNumber,id from DS_Property where  SysCatID={0}) as p2 where id=DS_Property.id) where SysCatID={0}", md.SysCatID);
         if (IsUp)
         {
             DS_Property p = ct.DS_Property.Single(a => a.ID == ID);
             DS_Property p1;
             if (p.Px > 1)
             {
                 p1 = ct.DS_Property.Single(a => a.Px == (p.Px - 1) && a.SysCatID == md.SysCatID);
                 p.Px--;
                 p1.Px++;
             }
         }
         else
         {
             DS_Property p = ct.DS_Property.Single(a => a.ID == ID);
             DS_Property p1;
             if (p.Px < ct.DS_Property.Where(a => a.SysCatID == md.SysCatID).Count())
             {
                 p1 = ct.DS_Property.Single(a => a.Px == (p.Px + 1) && a.SysCatID == md.SysCatID);
                 p.Px++;
                 p1.Px--;
             }
         }
         ct.SubmitChanges();
     }
 }
Exemple #4
0
 public void Update(DS_Property Property)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Property.Attach(Property, true);
         ct.SubmitChanges();
     }
 }
Exemple #5
0
 public void Add(DS_Property Property)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         ct.DS_Property.InsertOnSubmit(Property);
         ct.SubmitChanges();
     }
 }
Exemple #6
0
 public void Delete(int ID)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         var st = ct.DS_Property.Single(a => a.ID == ID);
         ct.DS_Property.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }
Exemple #7
0
 public void Delete(string Ids)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         string[] idarray = Ids.Split(',');
         var      list    = ct.DS_Property.Where(a => idarray.Contains(a.ID.ToString()));
         ct.DS_Property.DeleteAllOnSubmit(list);
         ct.SubmitChanges();
     }
 }
Exemple #8
0
 public List <DS_Property> Query(string condition, string orderby, params object[] param)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Property> PropertyList = ct.DS_Property;
         if (!string.IsNullOrEmpty(condition))
         {
             PropertyList = PropertyList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             PropertyList = PropertyList.OrderBy(orderby);
         }
         return(PropertyList.ToList());
     }
 }
Exemple #9
0
 public List <DS_Property> Query(string condition, string orderby, int startIndex, int pageSize, ref int pageCount, params object[] param)
 {
     using (var ct = new DS_PropertyDataContext(DbHelperSQL.Connection))
     {
         IQueryable <DS_Property> PropertyList = ct.DS_Property;
         if (!string.IsNullOrEmpty(condition))
         {
             PropertyList = PropertyList.Where(condition, param);
         }
         if (!string.IsNullOrEmpty(orderby))
         {
             PropertyList = PropertyList.OrderBy(orderby);
         }
         pageCount = PropertyList.Count();
         return(PropertyList.Skip(startIndex).Take(pageSize).ToList());
     }
 }