这是我的课:
public partial class Event
{
public Event()
{
this.Comments = new HashSet<Comment>();
this.Rates = new HashSet<Rate>();
this.RawDates = new HashSet<RawDate>();
}
public int ID { get; set; }
public string Title { get; set; }
public string Summary { get; set; }
public string SiteURL { get; set; }
public string ContactEmail { get; set; }
public string LogoURL { get; set; }
public int EventType_ID { get; set; }
public Nullable<int> Location_ID { get; set; }
public Nullable<System.DateTime> BegginingDate { get; set; }
public string nTrain { get; set; }
public string Content { get; set; }
public virtual ICollection<Comment> Comments { get; set; }
public virtual Conference Conference { get; set; }
public virtual ICollection<Rate> Rates { get; set; }
public virtual ICollection<RawDate> RawDates { get; set; }
public virtual EventType EventType { get; set; }
public virtual Location Location { get; set; }
}
当我调用 web api post 方法时,标题中提到的异常会在这一行中抛出:
var response = await client.PostAsJsonAsync("api/event", event);
我[JsonIgnore]
在 Event 类中的每个虚拟字段上方添加了。这次序列化工作了,但是忽略的字段没有被序列化,它们的值为空。我真的需要 Event 对象中包含的所有信息。我怎么解决这个问题?