实体框架实体sql vs linq到实体 [英] entity framework entity sql vs linq to entities

查看:74
本文介绍了实体框架实体sql vs linq到实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实体sql的目的是什么,我的意思是,如果您对实体有linq,为什么要用字符串编写查询,是否有任何性能原因或其他原因?

what's the purpose of entity sql, i mean if you have linq to entities why would you need to write queries in string, are there any performance reasons or something ?

推荐答案

LINQ to Entities不允许您访问数据库的所有功能。对于高级查询而言,有时有时需要进入数据库,要么首先将其拉出,要么改进LINQ to Entities系统对您的查询做出的有时可怕的选择。

LINQ to Entities does not allow you access to every feature of your database. Being able to "reach into" the database is sometimes necessary for advanced queries, either to pull them off in the first place or to improve the sometimes horrible choices that the LINQ to Entities system will make about your query.

也就是说,我相信LINQ to Entities应该是第一个达到的工具。如果性能成为问题,或者您遇到更复杂的问题,那么我会将那个问题片封装在存储过程中并调用它。如今,没有理由将字符串用作查询的基础。

That said, I believe that LINQ to Entities should be the first tool reached for. If the performance becomes a problem, or you have something more complex I would then encapsulate that problem piece in a stored procedure and call that. There is no reason for strings being used as the basis of queries these days.

这篇关于实体框架实体sql vs linq到实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆