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
Post a Comment