Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, July 12, 2010 8:44 AM
Hi
I wonder, can i specify which SQL index to use connected to an microsoft sql server express database?
For example, if i have a table named 'customer', and primary index is customerID,
and i also creare an index, say non-clustered on 'firstname' and 'lastname'
When using linq query:
var Result = DataContext.Customer.orderby(L=>L.Firstname).OrderBy(L=>L.Lastname);
Will Linq then use the best matching index in MS SQL server express, or can i specify that somehow?
Thanks for the help
//Niklas
All replies (3)
Monday, July 12, 2010 9:35 AM âś…Answered
well, as far as I know,
the index is used by sql to speed up the query execution (using additional internal data structures hence the extra storage required and the slower writes) and although you can use index hints you generally don't need to... the LINQ provider does not need to be part/aware of this process.
anyway, similar question answered here: http://stackoverflow.com/questions/2774606/how-do-i-get-linqtosql-to-pass-index-hints-to-sql-server
Leo
Monday, July 12, 2010 8:56 AM
Hello,
You don't need to specify it (as you wouldn't in SQL either)...
Leo
Monday, July 12, 2010 9:01 AM
Thanks,
so if i understand you correctly the Linq provider will use
the best index match? If there is more index than the primary index.
//Niklas