kala-tamin how do I use mvc data annotations in conjunction with auto generated linqtosql classes
صفحه اصلي

how do I use mvc data annotations in conjunction with auto generated linqtosql classes



I would like to be able to use DataAnnotations when working with my model, so for instance be able to write stuff like

[DisplayName("Title")] [StringLength(256)] public string title { get; set; } 

I also want to be able to use the column with linq which has led me so far to adding table and column linq mapping annotations such as

[Column(DbType = "NVarChar(256)", UpdateCheck = UpdateCheck.Never)] 

However this seems to be a long winded solution.

I would like to be able to use the auto generated linqtosql class but there doesn't seem to be a clear way to use this in conjunction with data annotations.

From research I have done I have come to the conclusion it is not possible to add the annotations using partial classes, and I don't want to have to create another class just for the annotations and start worrying about mapping the auto generated class manually. I also know it is bad practice to edit the code file of the auto generated class manually.

Is there a nice solution to this?


Are there any action filters in your project you feel are a must-have?

1:

New suggestions for error handling in ASP.NET MVC 2
The best way I found was this http://www.asp.net/mvc/tutorials/validation-with-the-data-annotation-validators-cs. ASP.NET WebForms with MVC localization issue
namespace MvcApplication1.Models {     [MetadataType(typeof(MovieMetaData))]     public partial class Movie     {     }       public class MovieMetaData     {         [Required]         public object Title { receive ; set; } 
Is it possible to map complex types with SolrNet

38 out of 100 based on 48 user ratings 368 reviews