c# - Is it better DLinq over IQueryable or DLinq over IEnumerable for better performance? -


if run against dlinq, example

var custq = data.storedbhelper.datacontext.customers ienumerable <data.so.customer>; 

i thought not of difference against running:

var custq = data.storedbhelper.datacontext.customers iqueryable <data.so.customer>; 

as, iqueryable inherits ienumerable.

but discovered following, if call: custq.sum() program process called .tolist() use 'as ienumerable' because memory on progam raised same level, when tried, custq.tolist.sum() not on 'as iqueryable' (because issue running on sql server) , did not affect memory usage of program.

my question this, should not use 'as ienumerable' on dlinq? 'as iqueryable' general rule? know if running standard iterations, gets same result, between 'as ienumerable'and 'as iqueryable'.

but summary functions , delegate expressions in statement there difference - or in general better performance if use 'as iqueryable'? (for standard iteration , filter functions on dlinq entities)

thanks !

well, depends on want do... casting ienumerable return object can enumerate... , nothing more. yes, if call count on ienumerable, enumerate list (so perform select query) , count each iteration.

on other hand, if keep iqueryable, may enumerate it, perform database operations were, orderby or count. delay execution of query , modify before running it.

calling orderby on enumerable browse results , order them in memory. calling orderby on queryable adds order @ end of sql , let database ordering.

in general, better keep iqueryable, yes... unless want count them browsing them (instead of doing select count(*)...)


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -