いくつかの複雑なプロパティを持つモデルがあります。
public class TestModel
{
public string Prop1 { get; set; }
public SubClass Prop2 { get; set; }
}
public class SubClass
{
public string Test { get; set; }
}
public class TestModelMetadata : ModelMetadataConfiguration<TestModel>
{
public TestModelMetadata ()
{
Configure(m => m.Prop1).DisplayName("is going to be displayed");
Configure(m => m.Prop2.Test).DisplayName("is NOT going to be displayed");
}
}
ビューにモデルを表示しようとしている場合:
@Html.LabelFor(m => m.Prop1)
@Html.LabelFor(m => m.Prop2.Test)
Prop2.Testではなく、Prop1の正しいラベルが表示されます。
誰かがその解決策を知っていますか?ありがとう!!!!!