Question: I have a clumsy way to get the max length of a column in the database, but it's so bad that it seems wrong:

```
var length = new DataNS.WidgetTable(provider).description.MaxLength

```

Do I really have to instantiate some object and go digging through it? I even have to pass a provider to it explicitly.

If this really is the right way to do it, what's the best to get the current provider to pass to it? If it's not, what is the best way?

Answer: 
If you use ActiveRecord then your object has a [COLUMN\_NAME]Column property which has all of this information. So if you have a Post object instantiated (like "post") you could use post.TitleColumn.MaxLength.

If you're using SubSonic 3 you can head in to Structs.tt and spin up whatever you need as well.
In subsonic 2.2 I do the following. Does this not work in 3?

```
var length = Template.Schema.GetColumn("Name").MaxLength;

```