TableNameAttribute(String) Konstruktor

Definíció

Inicializálja az TableNameAttribute osztály új példányát a tábla megadott nevével.

public:
 TableNameAttribute(System::String ^ name);
public TableNameAttribute(string name);
new System.Web.DynamicData.TableNameAttribute : string -> System.Web.DynamicData.TableNameAttribute
Public Sub New (name As String)

Paraméterek

name
String

A tábla neve.

Példák

Az alábbi példa bemutatja, hogyan állíthatja be a tábla nevét. A példában a megjelenített tábla neve "ProductModelProductDescriptions" értékről "Prod Model Desc" értékre módosul.

using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.DynamicData;

[MetadataType(typeof(ProductModelProductDescriptionMetaData))]
//[TableName(""Prod Model Desc")]
[DisplayName("Prod Model Desc")]
public partial class ProductModelProductDescription {
}

public class ProductModelProductDescriptionMetaData {

    [DisplayName("Modified")]
    [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
    public object ModifiedDate { get; set; }

    [DisplayName("Description")]
    public object ProductDescription { get; set; } 
}
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.Web.DynamicData


'<TableName("Prod Model Desc")> _
<MetadataType(GetType(ProductModelProductDescriptionMetaData))> _
<DisplayName("Modified")> _
Public Class ProductModelProductDescription

End Class


Public Class ProductModelProductDescriptionMetaData

    '<DisplayFormat(False, True, "{0:d}", True)> _
    <DisplayName("Modified")> _
    Public ReadOnly Property ModifiedDate() As Object
        Get
            Return ""
        End Get
    End Property


    <DisplayName("Description")> _
    Public ReadOnly Property ProductDescription() As Object
        Get
            Return ""
        End Get
    End Property

End Class

Megjegyzések

Az TableNameAttribute attribútum az entitás nevének módosítására szolgál a metaadatokban, ha több környezetből származó entitásnév-ütközések vannak. Az TableNameAttribute attribútum nem használható a megjelenítendő név módosítására. Ehelyett használja az DisplayNameAttribute attribútumot a megjelenítendő név módosításához.

A következőre érvényes: