using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Web; using Warehouse.Models.DTO; using Warehouse.Models.mesLevel4; namespace Warehouse.DAL.Config.MaterialCode { public class MaterialCodeMSDal { /// /// 查询物料料号 /// /// /// public List Query(Expression> whereExpression) { using (var context = new mesLevel4Model()) { //context.master_part.Join(context.df_part_type, // aa=>aa.part_type, // bb=>bb.part_type, // (aa, bb) =>new { aa,bb}).Where(a=>) return context.master_part.Where(whereExpression).Select(a => new MaterialCodeDto() { description = a.descriptions, flag = a.active_flag==1?true:false, partnumber = a.bom_part_nbr, parttype = a.df_part_type.descriptions, }).ToList(); } } /// /// 添加物料料号 /// /// /// public bool Add(master_part Obj) { using (var context = new mesLevel4Model()) { context.master_part.Add(Obj); return context.SaveChanges() > 0 ? true : false; } } /// /// 更新物料料号 /// /// /// public bool Update(master_part Obj) { using (var context = new mesLevel4Model()) { context.Entry(Obj).State = System.Data.Entity.EntityState.Modified; return context.SaveChanges() > 0 ? true : false; } } /// /// 查询物料类别 /// public List QueryPartType(Expression> whereExpression) { using (var context = new mesLevel4Model()) { return context.df_part_type.Where(whereExpression).Where(a=>a.active_flag==1).Select(a => new PartTypeDto { description = a.descriptions, flag = a.active_flag, parttype = a.part_type }).ToList(); } } public bool AddPartType(df_part_type Obj) { using (var context = new mesLevel4Model()) { context.df_part_type.Add(Obj); return context.SaveChanges() > 0 ? true : false; } } } }