LINQ

J

Jacek Jurkowski

I must to work with SQL Server database that
allow collumns to be null. F.e. column NREWID
in table K_OSOBY is Decimal 7 and accepts
NULLs. When creating DLINQ object of table
K_OSOBY vs net creates property NREWID
as Nullable<Decimal>. Is there any way to "tell"
vs net that it should create NREWID property just
as Decimal and use default value '0' in case of NULL
value in table K_OSOBY during fill?
As it is now I have to allways check if column
value isn't null before using it
(F.e. Decimal x = K_OSOBY.NREWID ?? 0)
wchich I would like to avoid ...
 
J

Jon Skeet [C# MVP]

I must to work with SQL Server database that
allow collumns to be null. F.e. column NREWID
in table K_OSOBY is Decimal 7 and accepts
NULLs. When creating DLINQ object of table
K_OSOBY vs net creates property NREWID
as Nullable<Decimal>. Is there any way to "tell"
vs net that it should create NREWID property just
as Decimal and use default value '0' in case of NULL
value in table K_OSOBY during fill?
As it is now I have to allways check if column
value isn't null before using it
(F.e. Decimal x = K_OSOBY.NREWID ?? 0)
wchich I would like to avoid ...

I don't have VS2008 to hand, but I know that in at least some cases
you can change the type of a column in the DBML diagram. (For
instance, I remember changing a "byte" column to actually be an enum).
Have you tried that, and if so what stopped it from working?

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top