BO Mapper DateTime C# Settings Issue


Author
Message
Jeff Pagley
Jeff Pagley
StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
I have been using Strataframe/VB.NET for some time now.  But I have been ask to develop an C#/ASP.NET Web app.  So I am new to all that.  I am trying to setup my field settings in the BO Mapper where I am assigning for my date fields the value of #1/1/1800# for Return Alternate on Null / Set Null on .... option.  C# code generated shows the compiler error 'Preprocesor directives must appear as the first non-whitespace character on a line.' for the following code:

if (value != #1/1/1800#)

What is wrong?  Also, in addition to this, is there anything else I need to be aware of when using C# vs VB.NET is setting up the BO Mapper stuff?

Thanks,

Jeff
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Jeff,

Instead of using a literal in the Return Alternate on Null, try something like this:
New DateTime(1800, 1, 1)


Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
I think you could also use DateTime.Parse("1/1/1800 00:00:00")


Here is a good comparison chart that could be handy for you:

http://www.harding.edu/fmccown/vbnet_csharp_comparison.html
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
The primary concept to understand is that the BOMapper is going to put whatever you type into the replacement value directly into code. Thus it must be valid for the language being used by the BO.  VB.NET has the date literal (#1/1/1800#) but C# does not. I use the method Edhy suggested myself, though it has to be valid C# so it has to be:

new DateTime(1800, 1, 1)


No semi-colon needed as it is inserted into lines of code, but the new keyword is lower case in C#.
Jeff Pagley
Jeff Pagley
StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)StrataFrame User (465 reputation)
Group: StrataFrame Users
Posts: 223, Visits: 893
Thanks Edhy/Greg that did the trick.  BTW Ivan the comparison chart is very helpful.  Thanks!
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Your are welcome Jeff!

Edhy Rijo

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
That is great, Jeff. Hope it helps. Wink
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad it helped Jeff!  And I used the chart Ivan posted a lot when I was learning C# after having programmed in VB.NET for a couple of years.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search