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