Tag: xrm

CRM 2011使用ICodeWriterFilterService生成的代码无法构建

使用http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html上的示例代码,我已对此进行了更改,以便GenerateEntity和GenerateOptionSet具有以下代码: return optionSetMetadata.Name.ToLowerInvariant().StartsWith(“myprefix”); 这将生成类型,包括选项集的一些枚举。 然而,实体中的optionset的实际实现并没有使用它,但我得到以下内容: [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute(“myprefix_fieldname”)] public Microsoft.Xrm.Sdk.OptionSetValue myprefix_FieldName { get { Microsoft.Xrm.Sdk.OptionSetValue optionSet = this.GetAttributeValue(“myprefix_fieldname”); if ((optionSet != null)) { return ((Microsoft.Xrm.Sdk.OptionSetValue)(System.Enum.ToObject(typeof(Microsoft.Xrm.Sdk.OptionSetValue), optionSet.Value))); } else { return null; } } set { this.OnPropertyChanging(“myprefix_FieldName”); if ((value == null)) { this.SetAttributeValue(“myprefix_fieldname”, null); } else { this.SetAttributeValue(“myprefix_fieldname”, new Microsoft.Xrm.Sdk.OptionSetValue(((int)(value)))); } this.OnPropertyChanged(“myprefix_FieldName”); } } 显然,将setSetValue转换为setter中的int不会编译,我假设它应该生成一个类型与生成的枚举匹配的属性,但不是。 我需要做些什么才能纠正这个问题?

无法访问Microsoft.Xrm命名空间

我已经下载了CRM Dynamics SDK并将其保存在本地目录中。 在我的代码中,我正在使用EntityCollection (在与Xrm名称空间相关的其他类中),这意味着我需要using Microsoft.Xrm.Sdk;进行添加using Microsoft.Xrm.Sdk; 。 问题是在编译期间我得到错误说: 命名空间“Microsoft”中不存在类型或命名空间名称“Xrm”(您是否缺少程序集引用?) 所以,我仔细检查引用是否已经完成,并且非常准确地说,我看到microsoft.xrm.sdk确实在我的列表中。 只是为了确定,我已经删除它并通过指向具有相同名称的DLL再次添加它。 但无济于事……令人讨厌的事情是,我的同事使用相同的代码并在机器上编译(唯一的区别是他在Win 7上,我在Win 8上)。 我们如何解决这个问题?

如何使用CrmServiceClient设置null属性值

我正在努力使用CrmServiceClient将属性值更新为null。 我的代码适用于非null值,但失败并出现exception: 你调用的对象是空的。 2 Field, AttributeCollection PropertyList) at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.UpdateEntity(String entityName, String keyFieldName, Guid id, Dictionary 2 fieldList,String applyToSolution,Boolean 2 Field, AttributeCollection PropertyList) at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.UpdateEntity(String entityName, String keyFieldName, Guid id, Dictionary中的Microsoft.Xrm.Tooling.Connector.CrmServiceClient.AddValueToPropertyList(KeyValuePair 2 Field, AttributeCollection PropertyList) at Microsoft.Xrm.Tooling.Connector.CrmServiceClient.UpdateEntity(String entityName, String keyFieldName, Guid id, Dictionary enabledDuplicateDetection,Guid batchId) 每当我尝试设置一个空值。 到目前为止,我尝试了以下内容: // create Crm service client object CrmServiceClient svc = […]