473,396 Members | 1,726 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,396 software developers and data experts.

Howto DOC (Data Object Component)

Hi,

I have a DOC, which represents a supplier.

Most of the class members are protected and I use public accessors to
access the class members.

One slight issue I have is that the values in my DB must sometime be
null. At the momenet my DOC represent the value as a value type.

Lets say I have a ContactID in my Supplier DataTable, which can either
be null or an ID of a contact in the contact table. At the moment my
DOC's class member is of type int, which can't be null.

How do you guys handle this scenario?

I suppose I could change all the relevant members to type "object", but
then I would have to cast/convert all those members each time I use
them at on the client.

Best,
Andre

Nov 17 '05 #1
4 1367
Andre,

Do you have the luxury of using .NET 2.0? If so, you can use Nullable
types (Nullable<T>) which will allow for value types to have null semantics.

If not, and you are exposing primitive types, you might want to check
out the types in the System.Data.SqlTypes, which support null semantics.

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

<ah****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

I have a DOC, which represents a supplier.

Most of the class members are protected and I use public accessors to
access the class members.

One slight issue I have is that the values in my DB must sometime be
null. At the momenet my DOC represent the value as a value type.

Lets say I have a ContactID in my Supplier DataTable, which can either
be null or an ID of a contact in the contact table. At the moment my
DOC's class member is of type int, which can't be null.

How do you guys handle this scenario?

I suppose I could change all the relevant members to type "object", but
then I would have to cast/convert all those members each time I use
them at on the client.

Best,
Andre

Nov 17 '05 #2
Hi Nicholas,

Sorry about the slow reply.

No I'm stil stuck in 1.1.4322.

Yeah I could have them as SqlTypes, but then I'd have to get rid of the
perks of .NET value types. But I suppose that (or similar) approach is
the only way forward.

Best,
Andre

Nicholas Paldino [.NET/C# MVP] wrote:
Andre,

Do you have the luxury of using .NET 2.0? If so, you can use Nullable
types (Nullable<T>) which will allow for value types to have null semantics.

If not, and you are exposing primitive types, you might want to check
out the types in the System.Data.SqlTypes, which support null semantics.

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

<ah****@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hi,

I have a DOC, which represents a supplier.

Most of the class members are protected and I use public accessors to
access the class members.

One slight issue I have is that the values in my DB must sometime be
null. At the momenet my DOC represent the value as a value type.

Lets say I have a ContactID in my Supplier DataTable, which can either
be null or an ID of a contact in the contact table. At the moment my
DOC's class member is of type int, which can't be null.

How do you guys handle this scenario?

I suppose I could change all the relevant members to type "object", but
then I would have to cast/convert all those members each time I use
them at on the client.

Best,
Andre


Nov 17 '05 #3
I came across this, which is pretty helpful.
Its still a bit of a pain to implement though.

ah****@gmail.com wrote:
Hi,

I have a DOC, which represents a supplier.

Most of the class members are protected and I use public accessors to
access the class members.

One slight issue I have is that the values in my DB must sometime be
null. At the momenet my DOC represent the value as a value type.

Lets say I have a ContactID in my Supplier DataTable, which can either
be null or an ID of a contact in the contact table. At the moment my
DOC's class member is of type int, which can't be null.

How do you guys handle this scenario?

I suppose I could change all the relevant members to type "object", but
then I would have to cast/convert all those members each time I use
them at on the client.

Best,
Andre


Nov 17 '05 #4
I came across this, which is pretty helpful.
Its still a bit of a pain to implement though.

http://dotnetjunkies.com/WebLog/mark...2/06/6724.aspx
ah****@gmail.com wrote:
Hi,

I have a DOC, which represents a supplier.

Most of the class members are protected and I use public accessors to
access the class members.

One slight issue I have is that the values in my DB must sometime be
null. At the momenet my DOC represent the value as a value type.

Lets say I have a ContactID in my Supplier DataTable, which can either
be null or an ID of a contact in the contact table. At the moment my
DOC's class member is of type int, which can't be null.

How do you guys handle this scenario?

I suppose I could change all the relevant members to type "object", but
then I would have to cast/convert all those members each time I use
them at on the client.

Best,
Andre


Nov 17 '05 #5

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

Similar topics

5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
0
by: joe mamma | last post by:
I know it works for basic widows form components. . . Similar approach can be applied for other controls if this doesn't work . . . Typical Usage: ============================= ArrayList...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
10
by: Rich | last post by:
Greetings, Just starting out with .net. I have a vb.net app where I connect to an Access mdb. I use a connection component from the tool box (conn1), a data adapter component from the toolbox...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
8
by: Topper | last post by:
Hello. I have simple web folders structure: -ROOT - BIN WebService.dll WebService.asmx I need to use my WebService.dll not in bin folder - for example, in ROOT. How do i this? How can i do...
1
by: peter.fredrikson | last post by:
Hi, I have a web server application (C#) which I would like to speed up a little. I would appriciate a discussion of design principles for a specific optimization scenario described below. My...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
13
by: Ben Voigt [C++ MVP] | last post by:
This is more of a C# question than a C++ question, but my best chance of explaining it is via comparison to C++. Ok: In C++ you can forward declare a type. Then references to that type can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.