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.
答案 0 :(得分:0)
我认为没有办法避免定义像People这样的类,但如果你真的想这样做,你可以在OData中尝试un-typed feature。
答案 1 :(得分:0)
Simple.OData.Client支持无类型的场景,其中不需要CLR类。
例如:
var people = await client.For("People").FindEntriesAsync();
然后,people
是一个字典实例,您可以使用IDictionary<string, object>
来引用。感谢。
答案 2 :(得分:0)
Simple.OData.Client支持类型化,无类型和动态方案。所以你可以像这样重写你的查询:
var x = ODataDynamic.Expression;
var people = await client.For(x.People).FindEntriesAsync();
这是另一个例子:
var person = await client
.For(x.People)
.Filter(x.FirstName == "John")
.Select(x.LastName)
.FindEntryAsync();