Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Dynamics CRM中的帐户GUID检索帐户号_C#_Linq_Dynamics Crm 2011_Guid - Fatal编程技术网

C# 使用Dynamics CRM中的帐户GUID检索帐户号

C# 使用Dynamics CRM中的帐户GUID检索帐户号,c#,linq,dynamics-crm-2011,guid,C#,Linq,Dynamics Crm 2011,Guid,我是LINQ的新手,所以如果我问错了问题,请道歉。我想使用帐户GUID和LINQ检索Dynamics CRM中的帐户号。但是找不到。我有以下代码段,但给出了一个异常,指定的强制转换无效 accountID = (Guid)contact["parentcustomerid"]; var account = from a in context.CreateQuery("account") where a.GetAttributeValue<Guid?>("accountid")

我是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)联系人[“parentcustomerid”];
var account=来自上下文中的一个。CreateQuery(“account”)
其中a.GetAttributeValue(“accountid”)==accountid
选择新的{accountNumber=a[“accountNumber”]};

什么是
accountID
<代码>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") };


什么是
accountID
<代码>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") };


尝试以下方法:

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();
var accountID=contact.GetAttributeValue(“parentcustomerid”).Id;
var accountnumber=(来自context.CreateQuery(“account”)中的
其中a.GetAttributeValue(“accountid”)==accountid
选择一个.GetAttributeValue(“accountnumber”).FirstOrDefault();

尝试以下方法:

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();
var accountID=contact.GetAttributeValue(“parentcustomerid”).Id;
var accountnumber=(来自context.CreateQuery(“account”)中的
其中a.GetAttributeValue(“accountid”)==accountid
选择一个.GetAttributeValue(“accountnumber”).FirstOrDefault();

service.retrieve返回“Microsoft.Xrm.SDK.Entity”,当我调试时,它只在属性中显示id。你能帮忙吗this@MohsinAli您是否指定了
new ColumnSet(“accountnumber”)
yes,这里是,Entity account=service.Retrieve(account.LogicalName,accountID,new ColumnSet(“accountnumber”)@MohsinAli如果
accountnumber
为空,则它将不在属性中。我确信它是空的。我甚至尝试了以下方法:ColumnSet col1=new ColumnSet();col1.Columns.Add(“accountnumber”);但是没有luckservice.retrieve返回“Microsoft.Xrm.SDK.Entity”,当我调试时,它只在属性中显示id。你能帮忙吗this@MohsinAli您是否指定了
new ColumnSet(“accountnumber”)
yes,这里是,Entity account=service.Retrieve(account.LogicalName,accountID,new ColumnSet(“accountnumber”)@MohsinAli如果
accountnumber
为空,则它将不在属性中。我确信它是空的。我甚至尝试了以下方法:ColumnSet col1=new ColumnSet();col1.Columns.Add(“accountnumber”);但是没有运气