随笔分类 -  EntityFramwork

摘要:案例代码如下: Model1Container ef = new Model1Container(); //查询 var liuyan = ef.LiuYan.Where(m => m.BH == "1").FirstOrDefault(); //查询后更新 liuyan.QQ = "1183816 阅读全文
posted @ 2018-11-03 09:53 飞刀软件 阅读(977) 评论(0) 推荐(0)
摘要:第一种:有局限性,只能使用主表的Rpl_WorkFlow里的字段排序 var list = LepulsDB.DBContext.Rpl_WorkFlow.Select() .Join(McDB.Com_Structure, (t, f) => t.Com_StructureID == f.Com_ 阅读全文
posted @ 2018-09-12 11:20 飞刀软件 阅读(1654) 评论(0) 推荐(0)
摘要:session.OrderBy(m=> m.SubmitStatus.Asc && m.CreateTime.Desc) //正确写法 session.OrderBy(m=> m.SubmitStatus.Asc).OrderBy(m=> m.CreateTime.Desc) //错误写法,第二次排 阅读全文
posted @ 2017-12-27 18:00 飞刀软件 阅读(1336) 评论(4) 推荐(0)
摘要:var session = LepulsDB.DBContext.ACC_ConfSeverity.Select(LepulsDB.ACC_ConfType,(t,f)=>t.Field(t.All,f.Name.Alias("TypeName"))) .Join(LepulsDB.ACC_Conf 阅读全文
posted @ 2017-12-12 19:41 飞刀软件 阅读(774) 评论(0) 推荐(0)
摘要:可以对ef使用lamda表达式动态添加参数查询: 案例如下: Func<Std_InspectionContentTableSchema, WhereClip> whereExp = p => { var whereClip = WhereClip.All; if (DangerLevel != n 阅读全文
posted @ 2017-06-16 11:03 飞刀软件 阅读(528) 评论(0) 推荐(0)
摘要:例子如下: DataAccess.InspectStandardDB.DBContext.Ji_InspectionContent.UpdateCustom() .Set(p => p.InspectionContent, mode.InspectionContent) .Set(p =>p.Num 阅读全文
posted @ 2017-06-14 16:47 飞刀软件 阅读(228) 评论(0) 推荐(0)
摘要:ef开发中会经常使用联表查询,有两种方式: 如果表中建立了外键关系,可以使用include方法,如下: var structure = McDB.DBContext.Com_Structure.Select().Include(m => m.Com_StructureType).Where(m => 阅读全文
posted @ 2017-03-31 13:44 飞刀软件 阅读(915) 评论(0) 推荐(0)
摘要:ef联表查询是使用EntityFramwork框架的项目都会用到,下面给的一个联表查询示例,几乎可以满足项目中所有的联表查询逻辑: var list = DBContext.Demo.Demo_User.Select(Demo.DataAcess.Demo.Demo_UserType, DataAc 阅读全文
posted @ 2017-03-21 10:37 飞刀软件 阅读(2911) 评论(0) 推荐(0)