c# - Retrieve Account Number using account GUID in Dynamics CRM -
i'm new linq please apology if ask wrong question. want retrieve account number in dynamics crm using account guid , linq. unable find. i've following snippet gives me exception specified cast not valid
accountid = (guid)contact["parentcustomerid"]; var account = in context.createquery("account") a.getattributevalue<guid?>("accountid") == accountid select new {accountnumber = a["accountnumber"] };
what accountid
? guid
or nullable<guid>
try below snippet:
accountid = (guid)contact["parentcustomerid"]; var account = in context.createquery("account") a.getattributevalue<guid>("accountid") == accountid select new {accountnumber = a.getattributevalue<int>("accountnumber") };
you can use query expression
. easy use:
queryexpression queryexpression = new queryexpression("account"); queryexpression.columnset = new columnset("accountnumber"); queryexpression.criteria.addcondition("accountid", conditionoperator.equal, accountid);
or
_service.retrieve("account", accountid, new columnset("accountnumber"));
Comments
Post a Comment