Width an decimal places of DbLinQ property

  • Thread starter Thread starter Andrus
  • Start date Start date
A

Andrus

I have lot of columns in database like

Price Numeric(5,2)
Street Character(30)

For UI display and validation I need to retrieve width and for numeric
properties, decimal places of corresponding DbLinq property.

pgsqlmetal generates code for column properies without width and decimal
places like

[Column(Name = "price", DbType = "numeric", CanBeNull = false)]
public decimal Price {
....

Which is best way to obtain width and decimal places of property:

1. Is there standard attributes which can be added to property ?
2. Should DbType attibute be DbType = "numeric(5,2)" or
DbType="character(30)" ?
3. Should I query database metadata directly using ADO .NET ?

Andrus.
 
Well, you could add your own attribute for your UI purposes. Other
than that, this is probably best directed at a pgsqlmetal/dblinq group
(or the blog), as it is quite specific to that technology.

Marc
 
Well, you could add your own attribute for your UI purposes. Other
than that, this is probably best directed at a pgsqlmetal/dblinq group
(or the blog), as it is quite specific to that technology.

Marc,

this may be general LinQ-SQL issue as well.
As MSDN states Column DbType attribute contains full server data type.

So I must parse DbType value manually to get field width and decimal places.
This is the only way, LinQ-SQL is not capable to return such important
instruction directly.

Andrus.
 
Andrus,

I wouldn't go about parsing the string in the data type. Personally, I
would do a query against the sys.columns information view to get the column
information in a format that is more easily dealt with.

Assuming that the structure of the tables doesn't change over the
lifetime of your app, you would only have to select this once, and then you
could cache the data.

Of course, the attribute will tell you which column to get the
information for.
 
Back
Top