steve2 wrote:
Three questions:
(1) The default for generated SELECT statements is to use Bind variables via sp_executesql (e.g. when a filter is used in FetchEntityCollection). This is great for INSERT's where you generally want to reuse the access plan and for filters on columns with uniform data distributions but this can be a problem for skewed data in large tables where different access plans are needed for different literals. Is there any way to override the use of Bind variables?
No, unfortunately not, as the sp_executeSQL call is made by the SqlClient, not by us. We simply generate a SQL statement and set the command type to Text. This will the SqlCommand then perform a EXEC sp_executesql ... to preserve the execution plan.
(2) Whenever an INSERT is generated, a SELECT is also generated. Is this to read back the row in case an IDENTITY value was generated? Is there any way to turn this off?
Only when an IDENTITY field is encountered, a select takes place (but this is part of the insert query, batched, and doesn't access tables). If you've specified to refetch the row after insert, it is refetched of course.
(3) The FetchEntity and FetchEntityCollection classes always fetch all columns of the result set. There appears to be a way to retrieve selected columns using projections on Typed Lists; however, I can't find any way of doing this for Entities. Is there a way?
At the moment projections are the way to go. In the upcoming upgrade you will be able to exclude fields for entity fetches so you can fetch entities and say exclude a couple of fields for a given fetch call and fetch them later on.