c# - Get another object while LINQ executing -


i don't know how explain clearly. trying properties while linq statement executing. example:

this working linq statement:

if (customerdata.demographics.count > 0) {     string[] communities = {"online_tech_comm", "online_prof_net", "online_tech_sections"};     var results = (from customerdemographic customerdemographic in customerdata.demographics (customerdemographic.userd2==datetime.minvalue)            select new models.memberonlinecommunitypreferences()            {                demographiccode = customerdemographic.demographiccodestring,                demographicsubcode = customerdemographic.demographicsubcodestring,      }).where(x=>communities.contains(x.demographiccode)).orderby(x=>x.demographiccode).tolist(); 

now, need pass demographiccodestring , demographicsubcodestring values

oapplicationsubcode = timss.api.cachedapplicationdata.applicationdatacache.get_applicationsubcode("cus", "demographic", demographiccodestring, demographicsubcodestring);  

and, check properties webenabled =="y" , active=="y", read customerdata , assign results. possible linq in single statement?

you need use "let" keyword.

https://msdn.microsoft.com/en-us/library/bb383976.aspx

var results = customerdemographic customerdemographic in customerdata.demographics  let code = customerdemographic.demographiccodestring  let subcode = customerdemographic.demographicsubcodestring  communities.contains(code) && customerdemographic.userd2==datetime.minvalue  let appsubcode = timss.api.cachedapplicationdata.applicationdatacache.get_applicationsubcode("cus", "demographic", code, subcode)  appsubcode.webenabled =="y" && appsubcode.active=="y"  select new models.memberonlinecommunitypreferences()        {            demographiccode = code,            demographicsubcode = subcode        }; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -