Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq to SQL - Underlying Column Length

Tags:

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.

like image 486
jwalkerjr Avatar asked Aug 21 '08 18:08

jwalkerjr


People also ask

Is LINQ faster than SQL?

Sql is faster than Linq. Its simple: if I m executing a sql query directly its a one way process whereas if I m using linq, first its been converted to sql query and then its executed.

Is LINQ to SQL deprecated?

LINQ to SQL was the first object-relational mapping technology released by Microsoft. It works well in basic scenarios and continues to be supported in Visual Studio, but it's no longer under active development.


1 Answers

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

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

like image 186
Stu Avatar answered Oct 13 '22 01:10

Stu