daryllabar / DLaB.Xrm.XrmToolBoxTools

Plugins for the XrmToolBox
MIT License
76 stars 69 forks source link

StateCode OptionSet missing for almost all Entities #235

Closed zaha closed 4 years ago

zaha commented 4 years ago

Hi,

I just noticed that the StateCode option sets are missing for all entites except the following 4:

But when looking at them, all are empty:

    public enum QuoteDetail_QuoteStateCode
    {
    }

except for OpportunityClose_OpportunityStateCode:

    public enum OpportunityClose_OpportunityStateCode
    {

        [System.Runtime.Serialization.EnumMemberAttribute()]
        [OptionSetMetadataAttribute("Lost", 2)]
        Lost = 2,

        [System.Runtime.Serialization.EnumMemberAttribute()]
        [OptionSetMetadataAttribute("Open", 0)]
        Open = 0,

        [System.Runtime.Serialization.EnumMemberAttribute()]
        [OptionSetMetadataAttribute("Won", 1)]
        Won = 1,
    }

Is there something wrong with my settings?

2020-04-24_XrmToolBox_bXbex27nPw

daryllabar commented 4 years ago

State Codes are generated in the Entity classes, and they're just postfixed with State. Sure you aren't getting confused? Also those entities are weird custom entities that truly don't have values: image

zaha commented 4 years ago

I see. I'm rolling my own entity classes as I do not want any dependency on the CRM SDK, so I only use the OptionSets from the EBG. Is there a reason why the status codes are part of the OptionSet export but the state codes aren't?

Would be really handy for me, but I understand that this might be an odd use case.

daryllabar commented 4 years ago

It's something that the CrmSvcUtil has always generated it as. Why are you rolling your own entities? Maybe the new .core sdk would be helpful?

zaha commented 4 years ago

I'm rolling my own entities for mainly two reasons:

Thanks for sharing the info about the .NET Core SDK. That would actually help me quite a lot with the second reason, since I have to use a Web API C# library right now that's not well maintained. But since it's still in early alpha I have to wait for a production-ready release.

That won't help, however, when using the enums in my SDK-independent DTOs. Guess I will have to take care of the state codes myself then. At least I can generate all the other option set enums, that already helps a lot.

Thanks for your support in any case!

daryllabar commented 4 years ago

I think it might makes sense to have an option to generate EarlyBound without any dependency on the Xrm Entity... I'll have to talk to Microsoft about that as well.

zaha commented 4 years ago

Now THAT would be awesome!

daryllabar commented 4 years ago

Would it need to have it's own Entity base class defined, or would you just want POCO (so no Attributes Collection, formatted values, etc)

zaha commented 4 years ago

I'm using an entity base class with an attributes collection since that allows for delta updates of only the changed attributes in my API. My derived entities provide properties for ease-of-access to these attributes in the collection, so pretty much what the generated early bound entities do from CrmSvcUtil, just without the dependency on Xrm.Entity.

For JSON serialization I marked only the ID, EntityLogicalName and Attributes collection properties as [DataMember] so the serializer ignores the redundant properties. Having only the redundant properties instead of the attribute collection in the JSON would produce nicer JSON, but I couldn't think of a way to do delta updates then as I can't differentiate between an attribute being set to null and not being set.

daryllabar commented 4 years ago

I'm going to close this issue, since the issue itself has been resolved.