在 Dynamics CRM 中使用帐户 GUID 检索帐号
Retrieve Account Number using account GUID in Dynamics CRM
我是 LINQ 的新手,所以如果我问错了问题,请道歉。我想使用帐户 GUID 和 LINQ 在 Dynamics CRM 中检索帐号。却找不到。我遵循了代码片段,但给了我一个例外,即 指定的转换无效
accountID = (Guid)contact["parentcustomerid"];
var account = from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid?>("accountid") == accountID
select new {accountNumber = a["accountnumber"] };
什么是accountID
? Guid
或 Nullable<Guid>
试试下面的代码片段:
accountID = (Guid)contact["parentcustomerid"];
var account = from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid>("accountid") == accountID
select new {accountNumber = a.GetAttributeValue<int>("accountnumber") };
您可以使用 Query Expression
。使用起来非常简单:
QueryExpression queryExpression = new QueryExpression("account");
queryExpression.ColumnSet = new ColumnSet("accountnumber");
queryExpression.Criteria.AddCondition("accountid", ConditionOperator.Equal, accountID);
或
_service.Retrieve("account", accountID, new ColumnSet("accountnumber"));
尝试如下操作:
var accountID = contact.GetAttributeValue<EntityReference>("parentcustomerid").Id;
var accountnumber = (from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid>("accountid") == accountID
select a.GetAttributeValue<string>("accountnumber")).FirstOrDefault();
我是 LINQ 的新手,所以如果我问错了问题,请道歉。我想使用帐户 GUID 和 LINQ 在 Dynamics CRM 中检索帐号。却找不到。我遵循了代码片段,但给了我一个例外,即 指定的转换无效
accountID = (Guid)contact["parentcustomerid"];
var account = from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid?>("accountid") == accountID
select new {accountNumber = a["accountnumber"] };
什么是accountID
? Guid
或 Nullable<Guid>
试试下面的代码片段:
accountID = (Guid)contact["parentcustomerid"];
var account = from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid>("accountid") == accountID
select new {accountNumber = a.GetAttributeValue<int>("accountnumber") };
您可以使用 Query Expression
。使用起来非常简单:
QueryExpression queryExpression = new QueryExpression("account");
queryExpression.ColumnSet = new ColumnSet("accountnumber");
queryExpression.Criteria.AddCondition("accountid", ConditionOperator.Equal, accountID);
或
_service.Retrieve("account", accountID, new ColumnSet("accountnumber"));
尝试如下操作:
var accountID = contact.GetAttributeValue<EntityReference>("parentcustomerid").Id;
var accountnumber = (from a in context.CreateQuery("account")
where a.GetAttributeValue<Guid>("accountid") == accountID
select a.GetAttributeValue<string>("accountnumber")).FirstOrDefault();