首页 / C# / 不要轻易使用linq代替sql
不要轻易使用linq代替sql
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了不要轻易使用linq代替sql,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2363字,纯文字阅读大概需要4分钟。
内容图文
![不要轻易使用linq代替sql](/upload/InfoBanner/zyjiaocheng/463/5be9fd9166f34ab985395f62302e27e9.jpg)
转化的SQL语句:
SELECT "Extent1"."personid", "Extent1"."projectid", "Extent1"."isallotroom", "Extent1"."randomcode", "Extent1"."admissionticket", "Extent1"."pushstatus", "Extent1"."createdtime", "Extent1"."examinationroomid", "Extent2"."id", "Extent2"."name", "Extent2"."idnumber", "Extent2"."gender", "Extent2"."mobile", "Extent2"."idcard", "Extent2"."email", "Extent2"."degree", "Extent2"."nation", "Extent2"."major", "Extent2"."graduatedate", "Extent2"."livingcity", "Extent2"."accountlocation", "Extent2"."expectcity", "Extent2"."enterprisenature", "Extent2"."expectindustry", "Extent2"."expectjob", "Extent2"."collegeid", "Extent2"."status", "Extent2"."signuptype", "Extent2"."createdtime" AS "createdtime1", "Extent2"."modifiedtime", "Extent2"."createdby", "Extent2"."modifiedby", "Extent2"."classname", "Extent2"."idcardtype", "Extent2"."birthday", "Extent2"."xzid", "Extent2"."szid", "Extent2"."testcity", "Extent2"."graduateschool", "Extent2"."degreeid", "Extent2"."nationid", "Extent2"."majorid", "Extent2"."accountlocationid", "Extent2"."livingcityid", "Extent2"."expectcityid", "Extent2"."enterprisenatureid", "Extent2"."expectindustryid", "Extent2"."expectjobid", "Extent2"."testcityid" FROM "public"."rel_project_person" AS "Extent1" INNER JOIN "public"."person" AS "Extent2" ON "Extent1"."personid" = "Extent2"."id" LEFT OUTER JOIN "public"."college" AS "Extent3" ON "Extent2"."collegeid" = "Extent3"."id" LEFT OUTER JOIN "public"."university" AS "Extent4" ON "Extent3"."universityid" = "Extent4"."id" WHERE "Extent1"."projectid" = 11 AND ("Extent4"."province" = ‘北京‘ OR "Extent4"."province" IS NULL )
linq转出来的语句在数据库上执行,花费40多秒:
Total query runtime: 40.1 secs 检索到 100127 行。
实现同样的业务,自己写的sql语句:
Select C.UNIVERSITYID,c.name,count(p.id) from Person p join Rel_Project_Person R on P.id =R.PersonID join College C on p.CollegeID = C.id where R.ProjectId =11 and C.universityid IN ( Select id from University where Province = ‘北京‘ ) group by C.UNIVERSITYID,c.name
执行自己写的sql,花费不到1秒:
Total query runtime: 680 msec 检索到 2 行。
不要轻易使用linq代替sql
标签:
本文系统来源:http://www.cnblogs.com/Fly-sky/p/5436036.html
内容总结
以上是互联网集市为您收集整理的不要轻易使用linq代替sql全部内容,希望文章能够帮你解决不要轻易使用linq代替sql所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。