Answered by:
DD Preview 2 - Scaffold model with TableNameAttribute name in Non-English lang problem

Question
-
User967562373 posted
In project i am using localized name of tables with TableNameAttribute.
For example:
#region TransportYear Table
[MetadataType(typeof(TransportYearMetaData))]
public partial class TransportYear {
}
[TableName("Descr in Non-english")]
public class TransportYearMetaData {
[ScaffoldColumn(false)]
public object TransportYearID { get; set; }
[DisplayName("Р_Р_Р_")]
public object Code { get; set; }
[DisplayName("Р"Р_Р_С<")]
public object Descr { get; set; }
}
#endregion
Now it doesn't work when we try to open the table. We can't use TableNameAttribute with Non-English name description?
Thursday, December 18, 2008 9:37 AM
Answers
-
User-1005219520 posted
You need to move the attribute to the class declaration. See http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.tablenameattribute.tablenameattribute.aspx
[TableName("Descr in Non-english")]
[MetadataType(typeof(TransportYearMetaData))]
public partial class TransportYear {
}
// [TableName("Descr in Non-english")]
public class TransportYearMetaData {
[ScaffoldColumn(false)]
public object TransportYearID { get; set; }
[DisplayName("Р_Р_Р_")]
public object Code { get; set; }
[DisplayName("Р"Р_Р_С<")]
public object Descr { get; set; }
}
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 18, 2008 12:46 PM -
User-1005219520 posted
I'll open a bug on the documentation. Here is a working example using the AdventureWorksLT DB
[DisplayName("Product Description")] [MetadataType(typeof(ProductDescriptionMD))] public partial class ProductDescription { public class ProductDescriptionMD { [DataTypeAttribute(DataType.Date)] [DisplayName("Modified")] public object ModifiedDate { get; set; } } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 18, 2008 1:28 PM
All replies
-
User-1005219520 posted
You need to move the attribute to the class declaration. See http://msdn.microsoft.com/en-us/library/system.web.dynamicdata.tablenameattribute.tablenameattribute.aspx
[TableName("Descr in Non-english")]
[MetadataType(typeof(TransportYearMetaData))]
public partial class TransportYear {
}
// [TableName("Descr in Non-english")]
public class TransportYearMetaData {
[ScaffoldColumn(false)]
public object TransportYearID { get; set; }
[DisplayName("Р_Р_Р_")]
public object Code { get; set; }
[DisplayName("Р"Р_Р_С<")]
public object Descr { get; set; }
}
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 18, 2008 12:46 PM -
User967562373 posted
I think there is now diff where we move TableNameAttr (before class declaration or metadata class). The problem with localized descr of table name.
In DynamicData version 1 everything is works, we can scaffold tables with Non-English descr (cyrillic). But in DD Preview 2 it doesnt work.
Also what are recommendations in using TableNameAttribute and DisplayNameAttribute?
Thursday, December 18, 2008 1:20 PM -
User-1005219520 posted
I'll open a bug on the documentation. Here is a working example using the AdventureWorksLT DB
[DisplayName("Product Description")] [MetadataType(typeof(ProductDescriptionMD))] public partial class ProductDescription { public class ProductDescriptionMD { [DataTypeAttribute(DataType.Date)] [DisplayName("Modified")] public object ModifiedDate { get; set; } } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 18, 2008 1:28 PM