ef、linq怎么实现以下的功能str sqlstr="select a.* from a"if (code1!="")sqlstr=sqlstr+" join b on a.id=b.id && b.code=code1"if (code2!="")sqlstr=sqlstr+" join c on a.id=c.id && c.code=code1".NET技术ASP.NET问题补充:在SQL Server Management Studio里直接运行select distinct(s.Title) from Table1 as si join Table2 as t on SUBSTRING(t.Code,1,12)='010101010108' and t.tid=si.tid join ST as st on SUBSTRING(st.Code,1,4)='0104' and st.stid=si.stid join S as s on SUBSTRING(s.SpellTitle,1,1)='C' and si.sid=s.sid where si.IsAudited='true' and si.IsDeleted='false' and si.IsVisable='true'第一次150ms,接下来都是50ms以下。但是在代码里 IEnumerable<SI> list = _dataContext.SI.Where(a => (filterModel == 1 ? a.IsAudited == true && a.IsDeleted == false && a.IsVisable == true : a.IsDeleted == false) && (Code == "" ? true : a.ST.Code.StartsWith(Code)) && (tid== 0 ? true : a.tid== tid)).Distinct(....);最少都在500ms以上,更甚的是,用老外的PredicateBuilder构建表达式,最少都在1.5m左右,这样明显有哪里做得不好.
- 2 回答
- 0 关注
- 688 浏览
添加回答
举报
0/150
提交
取消