views:

83

answers:

3

I'd swear I've seen this documented somewhere on MSDN site, but I cannot find it now - I'm searching for EF equivalent of Hibernate named queries - ability to encapsulate database specific sql queries in SSDL and then call them just like mapped stored procedures to get Entity Types in return.

[Edit] The rationale behind using it is optimization of linq/ESQL queries translated by EF Provider (sometimes they're awful).

A: 

Entity SQL and its related functionality might be what you're looking for.

Justin Swartsel
Entity SQL is not database-specific.
Devart
Yep, that should be ultimate mean to optimize queries unefficiently translated by given EF provider, so there's no difference between LINQ and entity SQL from that point of view.
deadbeef
+1  A: 

Create Function in SSDL and set CommandText to it like this is described here.
Then make Function Import for it like here.

Devart
A: 

OK, found it thanks to Devart's link (it's described in the same section) - they call it DefiningQuery

deadbeef
If you are going to work with DefiningQueries, you will have to create an entity in SSDL (with all columns returned by DefiningQuery), then an entity in CSDL and write the correct mappings in MSL.
Devart
You're right, Custom SSDL Function seems to fit better.
deadbeef