Search code examples
c#odata

OData dynamic template class


I am working with OData V3, and i came across this line:

var people = await client.For<People>().FindEntriesAsync();

In order for this to work, I need to define the People class, which has a bunch of set/get, which represent the fields I want.

Is there a simple and convenient way to avoid hard coding the structure classes? I want to be able to issue that command without having to define a specific "People" class. I would much rather have my results be in dictionary form, were the key's would be the column name, and the value would be the value in that column for the specific object.


Solution

  • Simple.OData.Client supports untyped scenarios, in which the CLR class is unnecessary.

    For example:

    var people = await client.For("People").FindEntriesAsync();
    

    Then, people is a dictionary instance that you can use IDictionary<string, object> to refer. Thanks.