Challenge: Getting Linq-to-Entities to generate decent SQL without unnecessary joins

后端 未结 3 1532
孤独总比滥情好
孤独总比滥情好 2021-02-10 13:14

I recently came across a question in the Entity Framework forum on msdn: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/bb72fae4-0709-48f2-8f85-31

3条回答
  •  别那么骄傲
    2021-02-10 13:27

    The SQL that linq generates is very efficient. It may look bulky but it takes into account relations on tables and constraints etc. In my opinion you should just blindly use the linq commands and not worry about scale. There are benefits of the large queries as its automatically generated. It avoids any slip ups in relational constraints and adds its own wrappers for faults/exceptions.

    If however you want to write the SQL's yourself and still want to work behind the confines of an ORM, then try iBatishttp://ibatis.apache.org/ You have to write the SQL's and joins yourself, so it gives you complete control over the backend model.

    Personally, just use SQLMetal and linq. Dont worry about performance and scale, unless you need to.

提交回复
热议问题