动态数据 - 创建友好的列名称? [英] Dynamic Data - Make Friendly Column Names?

查看:100
本文介绍了动态数据 - 创建友好的列名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个具有实体框架模型的动态数据项目。它的效果很好但是,现在它显示所有数据库表与db列名称 - 这并不总是最友好的(例如address_line_1)。我如何才能给这些更友好的列标题显示给最终用户?

I've created a Dynamic Data project with an Entity Framework model. It works nicely. But, right now it shows all my database tables with the db column names - which aren't always the most friendly (e.g. address_line_1). How can I got about giving these more friendly column titles that will display to the end user?

推荐答案

你应该使用元数据类添加其他注释:

You should use Metadata classes to add additional annotations:

[MetadataType(typeof(MovieMetaData))]
public partial class Movie
{
}


public class MovieMetaData
{
    [Required]
    public object Title { get; set; }

    [Required]
    [StringLength(5)]
    public object Director { get; set; }


    [DisplayName("Date Released")]
    [Required]
    public object DateReleased { get; set; }
}

http://www.asp.net/mvc/tutorials/validation-with-the-data-annotation-validators -cs - 使用实体框架查找使用数据注释验证器

http://www.asp.net/mvc/tutorials/validation-with-the-data-annotation-validators-cs - find Using Data Annotation Validators with the Entity Framework

属性不仅用于设置显示名称,还用于验证,转向可见性,顺序或者如何呈现数据。如果要使用动态数据实体项目,您应该查看它。

Attributes are used not only for setting display name, but also for validation, turning visibility, order or how data should be presented. You should look into it if you want to use Dynamic Data Entities project.

这篇关于动态数据 - 创建友好的列名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆