私はClientIndexModel
については、次の型階層を持っている:私のフルビューモデルがApiControllerによってシリアル化されていないのはなぜですか?
public class ViewModel
{
public virtual IDictionary<string, SelectList> SelectListDictionary
{
get
{
var props = GetType().GetProperties().Where(p => p.PropertyType == typeof(SelectList));
return props.ToDictionary(prop => prop.Name, prop => (SelectList)prop.GetValue(this, null));
}
}
}
public class IndexModel<TIndexItem, TEntity> : ViewModel where TIndexItem : ViewModel where TEntity : new()
{
public List<TIndexItem> Items { get; private set; }
}
public class ClientIndexModel: IndexModel<ClientIndexItem, Client>
{
}
私はインスタンス化し、次のようにApiControllerからClientIndexModel
を返す:
public ClientIndexModel Get()
{
var model = new ClientIndexModel();
return model;
}
私はreturn model;
行にブレークポイントをmodel
を検査した場合、 Items
プロパティが存在し、カウントは0ですが、このアクションから返されるJSONはSelectListDictionary
プロパティのみを持ち、Items
プロパティはありません。なぜこれができますか?
ありがとう、ありがとう。そのセッターは、私のインデックスモデルがすべて厳密に表示のみが強化されていた時代からの逆戻りです。まだそこにいないはずですが、私はそれがシリアル化を停止するとは決して推測できませんでした。 – ProfK