Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to force const inlining for generated query in LINQ to SQL?

LINQ to SQL always converts values into query parameters in the output. For example:

someTable.Where(n => n.Field == 5);

produces:

WHERE Field = @p0

This causes problems on certain query optimization scenarios. Is there a way to force values to be inlined in generated SQL, so that it becomes:

WHERE Field = 5

? Would LINQ to Entities provide a way or does it behave the same?

like image 495
Sedat Kapanoglu Avatar asked Dec 01 '14 09:12

Sedat Kapanoglu


1 Answers

As Diego Vega from Entity Framework team mentioned on Twitter:

constants have actually translated as inline constants in EF forever.

so it seems like EF is the way to go, with one catch:

We believe EF7 should parameterize more so we need to hear when that is a bad for you

at least EF6 is much better than LINQ to SQL in that manner so we can use EF instead.

like image 67
Sedat Kapanoglu Avatar answered Nov 15 '22 15:11

Sedat Kapanoglu