Apply wheres programmaticaly to the result of a store procedure in Linq to SQL -


given store procedure, 'mysp', takes 1 argument , returns set of results, filter resultset programmatically using list of conditions.

step1: store procedure added dbml file.

step2: code:

dim resultiqueryableset iqueryable(of myspautogeneratedtype) = datacontext.mysp(myparam).asqueryable() dim queryset iqueryable(of myspautogeneratedtype) = (from x in resultiqueryableset select x) each condition in listofcondition  queryset = queryset.where(function(el myspautogeneratedtype) el.condition = condition) next ' finally, prepare result dim resultset list(of myspautogeneratedtype) = queryset.tolist() 

step3: resultset becomes datasource of gridview

i'm wondering whether best approach. concern optimization. when running code, set of clauses applied once (at end, when .tolist() called) or there better way handling this.

if of help, i'm using vbnet, .net 4 , sql server 2008r2.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -