Why should I use int when searching for an object with the OptionSetValue attribute, but use the OptionSetValue object when creating the object?

I see inconsistency in how the CRM SDK considers searching for objects using the OptionSetValue attribute and creating an object with the OptionSetValue attribute.

Back panel:

I have a method with this signature

GetOrCreateEntity<T>(IOrganizationService service, params object[] columnNameAndValuePairs)

where columnNameAndValuePairs is a list of pairs that look like this: (column row name, column value), i.e. "name", "John Doe" is sent to entity.name = "John Doe".

It can be used as follows:

var user = GetOrCreateEntity<SystemUser>("username", "jdoe");

To create and execute a query expression for a SystemUser object with username jdoe. If it is not found, it will create one by filling out the username attribute "jdoe" and then creating the object.

Problem:

, / OptionSetValue. - :

var user = GetOrCreateEntity<SystemUser>("username", "jdoe", "Sex", new OptionSetValue(1));
var user = GetOrCreateEntity<SystemUser>("username", "jdoe", "Sex", 1);

OptionSetValue(1), , 1, , service.Create(entity) , OptionSetValue.

OptionSetValue int QueryExpression, , - . Microsoft , , OptionSetValue, int?

+5
1

Microsoft, / . , , FetchXml QueryExpression, DynamicEntity (CRM 4) Entity ( CRM 2011), /.

CRM 4, CRM wappers (CrmBoolean, CrmNumber), CLR, / . , EntityReference - . Guid, / EntityReference.

+2

All Articles