473,406 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Width an decimal places of DbLinQ property

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.
Nov 24 '07 #1
3 1685
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
Nov 24 '07 #2
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.
Nov 25 '07 #3
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.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andrus" <ko********@hot.eewrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>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.
Nov 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
4
by: italia | last post by:
I changed the Fieldsize Property from text to Long Integer and Decimal Places = 6. I had decimals in the original field. But after the transfer, the digits after the decimals are gone. Now...
3
by: paulquinlan100 | last post by:
Hi I have a couple of calculated fields in a report, i've set the Decimal Places property to 0 and the format to General Number, however when previewing the report it still comes up with a...
4
by: Hank | last post by:
Hello, I'm running Access 2000. I would like to know if its possible to use VBA code to determine how many decimal places are specified for each table field. Currently I loop throught the...
2
by: hunslair | last post by:
This is a really basic question. I am taking a teach yourself beginners course on Access 2003 and have run into a road block on one practice. In a select query, I have created a simple calculation...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
7
by: Andrus | last post by:
How to create format string for decimal data type which shows blank for zero and default format otherwize ? I tried format string "f;f;#" but this shows f for nonzero numbers. Andrus. ...
8
NeoPa
by: NeoPa | last post by:
I have noticed this over many versions of Access and was wondering if anyone could throw any light on why this seems to happen. It seems that when designing a QueryDef in the QBE grid and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.