これは私のクラスです:
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 クラスのすべての仮想フィールドの上に追加しました。今回はシリアル化が機能しましたが、無視されたフィールドはシリアル化されず、値は null です。Event オブジェクトに含まれるすべての情報が本当に必要です。どうすればこの問題を解決できますか?