これが私のビューモデルの場合:
public class ViewModel{
public string SimpleProperty{get;set;}
public SubViewModel ComplexProperty{ get;set;}
public SubViewModel[] ComplexPropertyArray{ get; set; }
}
public class SubViewModel{
public string NestedSimpleProperty{get;set;}
}
次に、ModelStateDictionary
for に割り当てられるデフォルトのエラー メッセージ キーは次のようになります。
ViewModel.SimpleProperty(以下の更新を参照)ViewModel.ComplexProperty(以下の更新を参照)ViewModel.ComplexProperty.NestedSimpleProperty(以下の更新を参照)ViewModel.ComplexPropertyArray(以下の更新を参照)- ViewModel.ComplexPropertyArray[0]
- ViewModel.ComplexPropertyArray[0].NestedSimpleProperty
更新 リフレクターでこれを見つけました:
protected internal static string CreateSubPropertyName(string prefix, string propertyName)
{
if (string.IsNullOrEmpty(prefix))
{
return propertyName;
}
if (string.IsNullOrEmpty(propertyName))
{
return prefix;
}
return (prefix + "." + propertyName);
}
#5 と #6を除くすべてを網羅していると思います。