Generating early bound entity classes for CRM Entities is fairly simple. Generating the Enums for the OptionSets is fairly simple as well. Generating the OptionSet Enum properties for entities that are typed to the correct Enum is not so simple, and not currently supported by the CrmSrvUtil.exe. If you want to be able to use the enums for populating the option set values, you have to continually write code that looks like this:
contact.Address1_AddressTypeCode = new OptionSetValue((int)contact_address1_addresstypecode.Home);
How do I generate Enum specific properties for OptionSetValues
, so I can write code like this:
contact.Address1_AddressTypeCode = contact_address1_addresstypecode.Home;
and so Address1_AddressTypeCode's
type is contact_address1_addresstypecode
?
I've created an Entity OptionSet Enum Mapper Utility to auto-generate Enum specific typed properties for early-bound entities. You can download both the source and executables here:
Programmatically Generating Properties for OptionSet Enums
It basically runs as part of a pre-build event during the build of your standard option set / enum dll, generating a .cs file that contains partial classes for any class that needs to have Enum properties generated for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With