我想通过 WCF Web Api 使用 Massive 进行数据访问,并从我的 Web api 返回动态或 ExpandoObject / IEnumerable<ExpandoObject>。
我基本上使用 JsonNetMediaTypeFormatter 工作,它使用 Json.NET 的 ExpandoObject 序列化,但所有内容都作为 Json 中的键值对返回,例如:
[
{
"Key":"ID",
"Value":"1000"
},
{
"Key":"FirstName",
"Value":"John"
},
{
"Key":"LastName",
"Value":"Smith"
}
]
但是,我想要的是:
[
{
"ID":"1000",
"FirstName":"John",
"LastName":"Smith",
}
]
好像我使用的是具体类型,例如:
public class Customer
{
public int ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
当从 WCF Web Api 返回时,关于如何将动态/ExpandoObject 格式化为具体对象的任何想法?