What is the benefit of using IQueryable and LINQ queries? -
i have project realized own configuration classes:
iconsizesconfigsection: configurationsection iconsizescollection: configurationelementcollection iconsize: configurationelement
in config
class exists property:
public iqueryable<iconsize> iconsizes { { iconsizesconfigsection configinfo = (iconsizesconfigsection)configurationmanager.getsection("iconconfig"); return configinfo.iconsizes.oftype<iconsize>().asqueryable<iconsize>(); } }
iconsizes
property returns iconsizescollection
derives configurationelementcollection
. in turn configurationelementcollection
derives icollection
, ienumerable
.
in class have such code:
var previewiconsize = config.iconsizes.firstordefault(c => c.name == "avatarsize");
why in such case uses deffered execution? why uses asqueryable<iconsize>()
collection , uses linq , deffered execution?
is there benefits compared using simple list?
in these case, there no practical benefit. using iqueryable
helpful cases when query rewriting/translation optimize performance. incur decreased performance in provided example.
one example of using iqueryable
in helpful way significant performance increase gained when lazily translating , evaluating queries against database or web service. perform better alternative of pulling massive result sets , applying query logic in active memory "simple list".
the way can tell using iqueryable
in case detrimental collection loaded memory, when begin query.
Comments
Post a Comment