【问题标题】:Is it possible to change the display name of EntitySet fields?是否可以更改 EntitySet 字段的显示名称?
【发布时间】:2012-05-19 19:36:32
【问题描述】:

每个外键都被定义为动态数据中的一个实体集。是否可以更改这些 EntitySet 字段的显示名称?

【问题讨论】:

标签: asp.net-dynamic-data


【解决方案1】:

是的。假设您有一个带有外键 CourseType 的课程。您可以将 DisplayAttribute 应用于课程:

[MetadataType(typeof(CourseMetadata))]
[DisplayName("Courses")]
public partial class Course 
{}

public class CourseMetadata
{
    [ScaffoldColumn(false)]
    public object CourseTypeId { get; set; }

    [Display(Name = "Course Type")]
    public object CourseType { get; set; }
}

【讨论】:

  • CourseTypeId是FK的名字,CourseType是子表的名字吗?
  • 每门课程都有一个 CourseType 并且 Course 表有一个 CourseTypeId 列。 CourseType 表有一个 Id PK 列(键入 Course.CourseTypeId)和一个 Name 列。
  • 我找到了答案。 [Display(Name="Course Type")] public EntityRef CourseType{get; set;} 这个解决方案解决了我的问题。
  • 我上面的建议是这样的;>
  • 无灰。 “公共对象”不起作用。我改用“公共EntityRef”。 ;)
猜你喜欢
  • 2018-10-12
  • 1970-01-01
  • 2020-06-08
  • 1970-01-01
  • 1970-01-01
  • 2011-05-29
  • 1970-01-01
  • 1970-01-01
  • 2011-01-21
相关资源
最近更新 更多