Linq to SQL – Underlying Column Length

linq-to-sql

I've been using Linq to SQL for some time now and I find it to be really helpful and easy to use. With other ORM tools I've used in the past, the entity object filled from the database normally has a property indicating the length of the underlying data column in the database. This is helpful in databinding situations where you can set the MaxLength property on a textbox, for example, to limit the length of input entered by the user.

I cannot find a way using Linq to SQL to obtain the length of an underlying data column. Does anyone know of a way to do this? Help please.

Best Answer

Using the LINQ ColumnAttribute to Get Field Lengths from your Database :

http://www.codeproject.com/KB/cs/LinqColumnAttributeTricks.aspx