473,566 Members | 2,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Managing optional dates in a business object

Hi all,

I have a property in one of my classes that represents an optional date.
I'm trying to figure out if I can represent Null or Nothing as the value for
a Date data type. Branching in the data access layer to send a Null to the
stored procedure is no problem, but managing a Null date in the business
object is another matter. I'm thinking of using a specific date (like
01-01-0001) to define the date as being empty/Null.

Any thoughts/ideas?

Éric
Nov 20 '05 #1
3 1280
"Eric Caron" <ec****@nospam. quebecaffaires. com> schrieb
Hi all,

I have a property in one of my classes that represents an optional
date. I'm trying to figure out if I can represent Null or Nothing as
the value for a Date data type. Branching in the data access layer
to send a Null to the stored procedure is no problem, but managing a
Null date in the business object is another matter. I'm thinking of
using a specific date (like 01-01-0001) to define the date as being
empty/Null.

Any thoughts/ideas?


3 thoughts:
- specific date
- property type: object
- wrapped date class

The latter:
class WrappedDate
public Value as Date
public sub new(byval value as date)
me.value = value
end sub
end class

Define the property as WrappedDate. Now the value can be Nothing which would
represent DBNull.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "Eric Caron" <ec****@nospam. quebecaffaires. com> scripsit:
I have a property in one of my classes that represents an optional date.
I'm trying to figure out if I can represent Null or Nothing as the value for
a Date data type. Branching in the data access layer to send a Null to the
stored procedure is no problem, but managing a Null date in the business
object is another matter. I'm thinking of using a specific date (like
01-01-0001) to define the date as being empty/Null.


You may want to use 'System.Data.Sq lTypes.SqlDateT ime'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Thank you Armin, that's a very clever way to manage it. I was hoping to get
away with this problem more easily, but I think I can't. Besides, your
method is more elegant than using a specific date.

Thanks again!

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************** @news.freenet.d e...
"Eric Caron" <ec****@nospam. quebecaffaires. com> schrieb
Hi all,

I have a property in one of my classes that represents an optional
date. I'm trying to figure out if I can represent Null or Nothing as
the value for a Date data type. Branching in the data access layer
to send a Null to the stored procedure is no problem, but managing a
Null date in the business object is another matter. I'm thinking of
using a specific date (like 01-01-0001) to define the date as being
empty/Null.

Any thoughts/ideas?
3 thoughts:
- specific date
- property type: object
- wrapped date class

The latter:
class WrappedDate
public Value as Date
public sub new(byval value as date)
me.value = value
end sub
end class

Define the property as WrappedDate. Now the value can be Nothing which

would represent DBNull.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

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

Similar topics

1
1767
by: Robert Zurer | last post by:
My architecture is, (ala Fowler PoEAA) Presentation Layer | Service Layer | Problem Domain (My Business Objects are held in memory) | Persistence Layer
11
2831
by: Peter Pfeiffer | last post by:
I've written several scripts that have "while" blocks which increment a date by one day if the date does not match one of a group of dates. However, sometimes it apparently steps out out the while loop even though my condition isn't met. Will work for a few loops then steps out often. Are there javascript "date" issues? I have also noticed...
21
4818
by: dub | last post by:
Hello web folks... I've been desigining web pages for 13 years using my trusty text editor (UltraEdit) and in depth knowledge of HTML. I'm truly a text editor ninja at this point. I am frequently using regular expressions to search and replace in multiple files. I also use many different copy buffers and know all the keyboard shortcuts like...
22
4127
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b) { return -1; } else
24
4402
by: PromisedOyster | last post by:
Is there a way that I can get a resultset that contains unique dates in a given date range without the need to have a temporary table and a cursor? perhaps something like: declare @start_date as datetime declare @end_date as datetime set @start_date as '1/1/2005' set @end_date as '1/1/2006'
4
6157
by: Gerry Abbott | last post by:
Hi All, Im trying to use thie combination but have not had success. Below is the function It tried the following myriskLevel(2,2) myrisklevel(0,0,2) and the ismissing(Three) alwasy returns false.?
10
6847
by: John Austin | last post by:
I am migrating my first vb6 app to vb.net 2003. In the vb6 app a number of subs had optional date parameters: Sub Fred ( ... ,optional FromDate as Date = 0...) I need something like zero in there to see if the parameter has been used or not. In vb.net the imported code fails with: Value of type 'Integer' cannot be converted to 'Date'
14
3252
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To make things simpler and better readable I'd make all default parameters named parameters so that you can decide for yourself which one to pass and...
2
11902
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a procedure. We weren't able to declare it with DateTime.MinValue as its default value, as MinValue is a read-only property rather than a constant. To...
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.