/// <summary> /// 复杂查询 /// </summary> /// <param name="model">查询对象</param> /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param> /// <param name="PageSize">每页行数,默认15</param> /// <param name="PageIndex">当前页码,默认100</param> /// <returns></returns> public DataGrid <T_SupplierModel> Search(T_SupplierModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100) { Expression <Func <T_Supplier, bool> > where = null; //最终查询条件 var lambdaList = new List <Expression <Func <T_Supplier, bool> > >(); //lambda查询条件集合 int total = 0; //总行数 if (model.COGS != null) { lambdaList.Add(c => c.COGS.Contains(model.COGS) || c.COGS2.Contains(model.COGS)); } if (model.Company != null) { lambdaList.Add(c => c.Company.Contains(model.Company)); } if (model.CategoryId != null && model.CategoryId > 0) { lambdaList.Add(c => c.CategoryId == model.CategoryId || (c.Category != null && c.Category.ParentId == model.CategoryId)); } //将集合表达式树转换成Expression表达式树 MyVisitor <T_Supplier, T_Supplier> visitor = new MyVisitor <T_Supplier, T_Supplier>(); where = visitor.Modify(lambdaList); var list = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList(); var result = new DataGrid <T_SupplierModel>() { rows = list, total = total }; return(result); }
public static T_Supplier ToModel(this T_SupplierModel node) { return(new T_Supplier() { Id = node.Id, COGS = node.COGS, COGS2 = node.COGS2, CategoryId = node.CategoryId, Company = node.Company, Rebates = node.Rebates, Cycle = node.Cycle, Contact = node.Contact, Hp = node.Hp, Tel = node.Tel, Tel2 = node.Tel2, Fax = node.Fax, Fax2 = node.Fax2, Email = node.Email, Remark = node.Remark, BankName = node.BankName, BankCode = node.BankCode, BankNumber = node.BankNumber, Collect = node.Collect, }); }
public static T_SupplierModel DTO(this T_Supplier node) { if (node == null) { return(null); } var model = new T_SupplierModel() { Id = node.Id, COGS = node.COGS, COGS2 = node.COGS2, CategoryId = node.CategoryId, Company = node.Company, Rebates = node.Rebates, Cycle = node.Cycle, Contact = node.Contact, Hp = node.Hp, Tel = node.Tel, Tel2 = node.Tel2, Fax = node.Fax, Fax2 = node.Fax2, Email = node.Email, Remark = node.Remark, BankName = node.BankName, BankCode = node.BankCode, BankNumber = node.BankNumber, Collect = node.Collect, Category = node.Category != null ? node.Category.Name:null, Parent_CategoryId = node.Category != null ? (node.Category.ParSysList != null ? node.Category.ParSysList.Id : 0) : 0, Parent_Category = node.Category != null ? (node.Category.ParSysList != null ? node.Category.ParSysList.Name : null) : null, }; return(model); }
public int DeleteData(T_SupplierModel model) { return(this.Delete(model.Id)); }
public int EditData(T_SupplierModel model) { return(this.Edit(model.ToModel())); }
public int AddData(T_SupplierModel model) { return(this.Add(model.ToModel())); }