Click here to Skip to main content
15,888,527 members
Home / Discussions / C#
   

C#

 
QuestionDataGridViewTextBoxEditingControl autocomplete conflict with wrapmode [modified] Pin
reza assar14-Feb-11 19:37
reza assar14-Feb-11 19:37 
Questionqueries with coding Pin
Rei ho14-Feb-11 18:43
Rei ho14-Feb-11 18:43 
QuestionRedirect after xsl file is downloaded Pin
S.Aijaz14-Feb-11 18:12
S.Aijaz14-Feb-11 18:12 
QuestionWhat is the better approach between IQueryable and IEnumerable ? Pin
Nadia Monalisa14-Feb-11 15:13
Nadia Monalisa14-Feb-11 15:13 
AnswerRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult14-Feb-11 17:16
mvePIEBALDconsult14-Feb-11 17:16 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
Nadia Monalisa14-Feb-11 17:59
Nadia Monalisa14-Feb-11 17:59 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 1:53
mvePIEBALDconsult15-Feb-11 1:53 
AnswerRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight14-Feb-11 21:25
dasblinkenlight14-Feb-11 21:25 
It is important to understand the difference between the two: IQueryable pushes the query logic into RDBMS, while IEnumerable does things in the main memory. Although IQueryable cannot perform certain things that IEnumerable can because of the need to translate query logic to SQL, you should try really hard to push as much logic as you can onto the IQueryable side. The reason for it is the data transfer and memory costs: once you call ToList/ToArray, the data described by the query to the left of it gets copied into main memory.
Your own interfaces should rarely expose IQueryable for two major reasons - one is the deferred execution, and the other is query translation. If your class returns IQueryable, the RDBMS will be called at the time the caller decides to go through the results for the first time, which may happen significantly later than your code returns. If callers tend to not enumerate the results at all in a significant number of cases, calling AsEnumerable instead of ToLost/ToArray may save you some unnecessary roundtrips to RDBMS; if callers go through your query results immediately, you are better off calling ToList/ToArray yourself. The other reason to not expose IQueryable in your data layer is to avoid errors when your callers apply LINQ methods to your results: these LINQ queries will be translated to RDBMS, potentially resulting in run-time errors.
As a side note, if this is a new project, using Entity Framework instead of LINQ to SQL is highly advisable: at this point, LINQ to SQL technology receives only bug fixes from Microsoft; the new development is concentrated in EF. The good news is that much of what you learned about querying in LINQ to SQL applies in EF as well.
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 2:02
mvePIEBALDconsult15-Feb-11 2:02 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 2:31
dasblinkenlight15-Feb-11 2:31 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 4:19
mvePIEBALDconsult15-Feb-11 4:19 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 5:15
dasblinkenlight15-Feb-11 5:15 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 8:32
mvePIEBALDconsult15-Feb-11 8:32 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
dasblinkenlight15-Feb-11 9:40
dasblinkenlight15-Feb-11 9:40 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 10:03
mvePIEBALDconsult15-Feb-11 10:03 
GeneralRe: What is the better approach between IQueryable and IEnumerable ? Pin
PIEBALDconsult15-Feb-11 10:09
mvePIEBALDconsult15-Feb-11 10:09 
QuestionControl Speaker Volume Pin
Kevin Marois14-Feb-11 8:21
professionalKevin Marois14-Feb-11 8:21 
AnswerRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 9:15
professionalDaveyM6914-Feb-11 9:15 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 10:27
professionalKevin Marois14-Feb-11 10:27 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 10:58
professionalDaveyM6914-Feb-11 10:58 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:03
professionalKevin Marois14-Feb-11 11:03 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:36
professionalKevin Marois14-Feb-11 11:36 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 11:45
professionalDaveyM6914-Feb-11 11:45 
GeneralRe: Control Speaker Volume Pin
Kevin Marois14-Feb-11 11:49
professionalKevin Marois14-Feb-11 11:49 
GeneralRe: Control Speaker Volume Pin
DaveyM6914-Feb-11 11:58
professionalDaveyM6914-Feb-11 11:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.