c# 4.0 - Linq to XML + chaining expressions -


i have following code that's repeated:

var ccanumber = (from r in xdoc.elements("resultset").elements("datarow")          convert.toint32(r.element("paymentplannumber").value) == payplan.ordernumber 

ideally, want create above expression add clause end of it.

so, created expression follows:

expression currexp = r in xdoc.elements("resultset").elements("datarow") convert.toint32(r.element("paymentplannumber").value) == payplan.ordernumber; 

i want combine them:

 var ccanumber = (currexp  select r.element("creditcardauthoritynumber").value).firstordefault(); 

however following error:

invalid expression term ')'

any suggestions?

ta,

yogi

i think mixing things here.

what can is:

var items = r in xdoc.elements("resultset").elements("datarow")             convert.toint32(r.element("paymentplannumber").value) == payplan.ordernumber              select r; 

this declares items enumerable of elements match where-condition.

and can use defined items this:

var ccanumber = items.select(item=>item.element("creditcardauthoritynumber").value).firstordefault(); 

however, utilising lazy evaluation , need take care of multiple enumerations here. here pretty indepth explanaition way better sh*tty english.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -