Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> DateRange purgatory
 

Pages: 1
LLBLGen Pro Runtime Framework
DateRange purgatory
Page:1/1 

  Print all messages in this thread  
Poster Message
Stoop
User



Location:
Reno, Nevada
Joined on:
28-Feb-2004 12:01:28
Posted:
66 posts
# Posted on: 11-Jun-2004 10:46:59.  
Hi

I have a SQL Server table with 2 fields (smalldatetime): ArrivalDate & DepartureDate

What I need to do is return ONLY (the key word!!) the records in the table where a date parameter is greater than or equal to ArrivalDate OR the date parameter is less than the DepartureDate.

Sounds simple on paper but I'm having the hardest time tying to get this to work using the predicate expression factory.

I have a feeling I need to be using the FieldCompareRangePredicate, but, seeing as there are no examples of how to use this in the help, I was hoping someone could help me out on this one..

TIA
Steve
  Top
uydo
User



Location:
dallas,tx
Joined on:
09-Dec-2003 21:33:50
Posted:
43 posts
# Posted on: 11-Jun-2004 17:00:30.  
Hi Steve,
You can do something like this:
1. Create a separate predicate expression for the ArrivalDate & DepatureDate only:
Code:

IPredicateExpression filterCompareDate = new PredicateExpression();
filterCompareDate.Add(PredicateFactory.CompareValue(<Table>FieldEntity.ArrivalDate, ComparisonOperator.LessThanEqual, ArrivalDate1));
filterCompareDate.AddWithOr(PredicateFactory.CompareValue(<Table>FieldIndex.DepartureDate, ComparisonOperator.GreaterThan, DepatureDate1));

2. Then add this predicate into your main predicate!.
Code:

IPredicateExpression filter = new PredicateExpression();
//filter.Add(PredicateFactory.CompareValue(<Table>FieldEntity.a, ComparisonOperator.Equal, b));;
filter.AddWithAnd(filterCompareDate);


This code generates something like this:
Quote:

select ...
from...
where a=b and (<Table>.ArrivalDate LTE ArrivalDate1 OR <Table>.DepartureDate GT DepartureDate1)


I see there is a good example in the the doc that explains predicate expression very well.

HTH,
Uy



  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37319 posts
# Posted on: 11-Jun-2004 17:21:10.  
Also take into account that SqlServer stores the time with date values, always. So if you want to test for a given date, you have to test with BETWEEN using as time 00:00 and 23:59.59
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Stoop
User



Location:
Reno, Nevada
Joined on:
28-Feb-2004 12:01:28
Posted:
66 posts
# Posted on: 11-Jun-2004 19:21:14.  
Thx Otis - I'll give it a go!

Steve

PS Yes, I did see the example in the help. However, I was (in my project) off on another tangent trying stuff. Just needed a push in the right direction is all...


  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.