Howto DOC (Data Object Component)

  • Thread starter Thread starter ahaupt
  • Start date Start date
A

ahaupt

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
 
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.
 
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
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]
- (e-mail address removed)

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
 
I came across this, which is pretty helpful.
Its still a bit of a pain to implement though.
 
Back
Top