使用示例代码在http://erikpool.blogspot.com/2011/03/filtering-generated-entities-with.html我已经改变了这一点,以便GenerateEntity和GenerateOptionSet有代码:CRM 2011生成的代码使用ICodeWriterFilterService构建失败
return optionSetMetadata.Name.ToLowerInvariant().StartsWith("myprefix");
这将生成类型,包括一些枚举了optionsets。在实体optionset的实际执行不但是用这个,但我得到以下几点:
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("myprefix_fieldname")]
public Microsoft.Xrm.Sdk.OptionSetValue myprefix_FieldName
{
get
{
Microsoft.Xrm.Sdk.OptionSetValue optionSet = this.GetAttributeValue<Microsoft.Xrm.Sdk.OptionSetValue>("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");
}
}
显然铸造OptionSetValue在二传手不编译一个int,我认为它应该产生该属性的类型与生成的枚举相匹配,但不是。我需要做些什么来纠正这个问题?
将这项解决方案的帮助? http://stackoverflow.com/a/8967568/1114306 –