私は次のタイプ階層を持っていますClientIndexModel
:
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>
{
}
ClientIndexModel
次のように、ApiControllerをインスタンス化して返します。
public ClientIndexModel Get()
{
var model = new ClientIndexModel();
return model;
}
行にmodel
ブレークポイントを設定して検査すると、プロパティは存在し、カウントは0です。ただし、このアクションから返されるJSONにはプロパティのみがあり、プロパティはありません。なぜこれができるのでしょうか?return model;
Items
SelectListDictionary
Items