entity framework entity sql vs linq to entities

后端 未结 2 1644
無奈伤痛
無奈伤痛 2020-12-31 14:44

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 ?

2条回答
  •  庸人自扰
    2020-12-31 15:29

    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.

    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.

提交回复
热议问题