Pregunta

Me estaba preguntando si hay situación que es más recomendable utilizar ESQL?

En general, encuentro ESQL frustrante (especialmente con todos los casos especiales en los que necesita para calificar totalmente un tipo de entidad) y, probablemente, cualquier cosa hecha usando ESQL puede hacerse a través de SQL o LINQ.

Pero me preguntaba de situaciones en las ESQL es un mejor ajuste para una solución o tendría una ventaja competitiva sobre el uso de SQL o LINQ (ya sea más fácil / más rápido al código, o mejor rendimiento, etc.)

Así que, ¿cuál es el compromiso aquí? ¿Cuándo es mejor utilizar cada uno de los tres enfoques en la consulta sobre EF4?

¿Fue útil?

Solución

I find that ESQL to be good for edge cases, for example:

  1. Where it's just really hard to express something in LINQ.
  2. For building very dynamic searches.
  3. If you want to use a database specific function that is exposed by the provider you are using.

Also, if you know Entity SQL, you will be able to express QueryViews and Model-Defined Queries.

Otros consejos

I came across these pretty similar questions (which didn't show up when I typed mine, earlier) on stack over flow, I guess they have deeper discussions (though T-SQL is not mentioned a lot, but it's kinda pretty obvious though):

Note that the two questions are a bit "old" so you might validate some of data based on your current understanding of EF4

Just as what julie mentioned. Esql is required to write model defined functions which in return can be used through LINQ to Entities Queries. Most cased you'll be using LINQ to Entities. One another case where you can't use LINQ TO Entities us when you want to build queries with store functions, either buit in or UDF. In this case esql is your only way in EF1 but in EF4 you can use its features to expose those functions to be used in LINQ. About performance, esql is performing better. but you might prefer productivity using Linq over performance gain using esql.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top