想隐藏正映射到JSON的EntityData对象

时间:2015-12-16 13:31:14

标签: json entity-framework asp.net-web-api2

如何隐藏在webapi的post方法中映射到JSON的EntityData对象

例如:     EntityData对象位于

之下
public DateTimeOffset? CreatedAt { get; set; }
public bool Deleted { get; set; }
public string Id { get; set; }
public DateTimeOffset? UpdatedAt { get; set; }
public byte[] Version { get; set; }

My Model looks like

public class area : EntityData
{
public string name {get;set;}
public string arealabel{get;set;}
}

so json object returns is

{
  "name": "sample string 1",
  "arealabel": "sample string 2",
  "id": "sample string 3",
  "__version": "QEBA",
  "__createdAt": "2015-12-16T13:18:22.752Z",
  "__updatedAt": "2015-12-16T13:18:22.752Z",
  "__deleted": true
}

But i need only name and arealabel to be shown in JSON object during post method
instead of writing request object separately. The json object should be like below

{
  "name": "sample string 1",
  "arealabel": "sample string 2"
}

目标是在post方法中隐藏entitydata对象

0 个答案:

没有答案