This project is read-only.

select columns in query

Apr 16, 2011 at 10:23 AM

i am using the following query to limit the columns to return from a table 

Dim var = From o As comp.Business.Objects.User In comp.Business.Objects.UserCollection.RunSelect Select o.PKID, o.FullName, o.login

In performance terms,  does this run the select statement with only the columns i define ?

Or does it get the entire result set and then filter the columns from the select statement ?

Just asking to know if i am gaining the performance from limiting the select statement.

I know about components and views to define in the model but i need to set the select statement at run time , without going to the model.



Apr 23, 2011 at 6:05 PM

You are using the NHDAL and if you call the "RunSelect" method with no parameters (like you are doing) it really just runs a stored procedure in the background that does not change but selects all columns. If you want real control over the fields selected you will need to use the EFDAL that is built on top of Entity Framework. This gives you finer detail of select operations. Remember there are 2 data access layers that can be generated with nHydrate: NHDAL and EFDAL.

May 2, 2011 at 11:55 PM

Just an afterthought but even though this syntax does not limit columns retrieved it does limit data returned from the server. If you pass a LINQ Where statement into the RunSelect method it will issue a where statement to SQL as a filter. If you use the EFDAL it you can limit the columsn as well by using the "Select" projection syntax.