locked
Create open types in OData V4 without a dictionary RRS feed

Answers

  • User36583972 posted

    Hi z26zheng,

    From your description, You can create an open-less complex type without IDictionary extra property.

    Open complex type model:

    It’s quite easy to define a model with open complex type. You should only add an extra property with IDictionary<string, object> in your CLR class.

    public class Press 
     { 
         public string Name { get; set; } 
      
         public string Web { get; set; } 
      
         public Category Category { get; set; } 
      
         public IDictionary<string, object> DynamicProperties { get; set; } 
     } 

    Open-less complex type.
    An CLR class without IDictionary extra property

    public class Address 
     { 
         public string City { get; set; } 
      
         public string Street { get; set; } 
     } 

    You can refer the following tutorial.

    [Tutorial & Sample] Open complex type step by step with Web API 2.2 for OData v4.0:

    https://blogs.msdn.microsoft.com/odatateam/2014/07/20/tutorial-sample-open-complex-type-step-by-step-with-web-api-2-2-for-odata-v4-0/

    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 20, 2016 6:02 AM