locked
ODataConventionModelBuilder conventions RRS feed

  • Question

  • Hi all, 

    I generate IEdmModel from ODataConventionModelBuilder and as soon as I see there are conventions which dictate me to mark my DTO classes with DataContract and DataMember attributes. Is there any possibility to change these conventions?
    I found a hack but it looks a bit tricky: 

        public class ODataModelBuilderExtended : ODataConventionModelBuilder
        {
            static ODataModelBuilderExtended()
            {
                Type type = typeof(ODataConventionModelBuilder);
                FieldInfo info = type.GetField("_conventions", BindingFlags.NonPublic | BindingFlags.Static);
                IList value = (IList)info.GetValue(null);
                value.Remove(value[1]);
                value.Remove(value[3]);
                value.Remove(value[10]);
            }
        }

    Thanks in advance for your help.
    Artem.

    Tuesday, January 6, 2015 10:28 AM