updating dynamic properties using simple.odata.client

974 Views Asked by At

I have the following class in server

namespace ServerNameSpace.Models
{
    public class Product
    {
      [Key]
      public int Id { get; set; }
      [Key]
      public string Name { get; set; }
      public IDictionary<string, object> DynamicProperties {get; set;} 
   }
}

I am trying to update the dynamic properties of above class from client. In the below example "Manufacturer" is a dynamic property which resides in server. When I try to update it using following code I am getting error The property 'Manufacturer' does not exist on type 'ServerNameSpace.Models.Product'. Make sure to only use property names that are defined by the type in the client. I couldn't see any request to the server in fiddler.

static async void test()
{
    ODataClient client = new ODataClient("http://localhost.fiddler:58460/");
    Dictionary<string, object> keys = new Dictionary<string, object>()
    {
            {"Id", 123},
            {"Name", "ABC"}
    };
    await client.For("Products").Key(keys).Set(new Dictionary<string,object>()
            {
                {"Manufacturer","Me"}
            }).UpdateEntryAsync();
}

How do I update the properties of the object that has dynamic properties ?. Any help would be appreciated.

1

There are 1 best solutions below

0
On

Have a look at my answer to a similar question, there is a link to sample code that handles open properties.

Does Simple.OData.Client support open properties?