This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi,
I have attached a TraceLogger to my context to analyse what type of query was executed with my linq query and I want to know if it is possible to build a linq query that execute behind the scene a query string with only one column.
Here is a example of my linq query: Repository.Query().Single(Function(s) s.Id = model.Id).Code
With the TraceLogger, this produce: SELECT
What I want is that the query look like this: SELECT
I know that all this stuff is hidden but I will use this type of query a lot of time and if it is possible to optimize the performance, I wil be very glad.
Thank you. |
|
|
Use the Select operator, e.g. Select(s => s.Code). Select causes LightSpeed to select only the columns required for the output. |
|
|
Thank you very much, this is exactly what I want. I use in my code Query.Where(s => s.Id = 10).Select(s => s.Code) I think in this case that I must not try to know if you have optimize the query to use ExecuteScalar or ExecuteReader. I don't know if the ExecuteScalar is more performant than ExecuteReader to read the first value of the first column. In anyways, this work fine.
Thank you again. |
|