between

Posts   
 
    
Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 26-Oct-2004 16:59:11   

Hi all

small question about the FieldBetweenPredicate I know I can do something like :

SELECT ... WHERE field BETWEEN value1 AND value2

But .. how to do something like :

SELECT ... WHERE value BETWEEN field1 AND field2

Any help ? I didn't find anything even with the expression ... Thanks !

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 26-Oct-2004 17:25:01   

The betweenpredicate doesn't support fields indeed, you have to do that with some extra code and 2 fieldcompareexpression predicates.

I admit, pretty clumbsy, added to the todo list. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Fabrice
User
Posts: 180
Joined: 25-May-2004
# Posted on: 26-Oct-2004 18:14:00   

Héhé ok thanks Yes it wasn't too hard to find another way to do the work. It'll just be easier with the "value between field".

As we're speaking about the todo list, could you add an option to automaticly rename entity fields name when the db mapping is renamed ? Because (as a lot of people I think), I always keep the 'same' name between llblgen and the db.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 26-Oct-2004 20:07:36   

Fabrice wrote:

Héhé ok thanks Yes it wasn't too hard to find another way to do the work. It'll just be easier with the "value between field".

As we're speaking about the todo list, could you add an option to automaticly rename entity fields name when the db mapping is renamed ? Because (as a lot of people I think), I always keep the 'same' name between llblgen and the db.

That option is planned yes.

'same' is a bit subjective I think. Databases like firebird and Oracle which have solely uppercase field names, are probably not the same but I'll find some solution for that wink

Frans Bouma | Lead developer LLBLGen Pro
bjtomli
User
Posts: 12
Joined: 17-Feb-2012
# Posted on: 17-Feb-2012 02:38:00   

Otis wrote:

The betweenpredicate doesn't support fields indeed, you have to do that with some extra code and 2 fieldcompareexpression predicates.

I admit, pretty clumbsy, added to the todo list. simple_smile

I know this is a old thread but I'm using version 3.1 and I still don't see a way to put the value as the left operator using a BetweenPredicate as such...

filter.Add(new FieldBetweenPredicate(value, VRackPriceFields.EffectiveFromDateTime, VRackPriceFields.EffectiveFromDateTime));

I'd expect this to generate the following SQL when added to my filter...

AND @value BETWEEN EffectiveFromDateTime AND EffectiveToDateTime

Am I missing something or has this still not been implemented in version 3.1? If it has can you give example of how to do this>

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Feb-2012 03:30:47   

Only these combinations are supported for FieldBetweenPredicate: FIELD between VALUE1 and VALUE2 FIELD between VALUE1 and Field2 FIELD between Field2 and VALUE1 FIELD between Field2 and Field3

It also was discarded of the to-do list as now is much easier to write predicates. If you want VALUE BETWEEN FIELD 1 AND FIELD 2, you have to use two combined predicates:

filter.Add(date1 >= OrderFields.Date1 AND date2 <= OrderFields.Date2);
David Elizondo | LLBLGen Support Team
bjtomli
User
Posts: 12
Joined: 17-Feb-2012
# Posted on: 21-Feb-2012 00:10:18   

daelmo wrote:

Only these combinations are supported for FieldBetweenPredicate: FIELD between VALUE1 and VALUE2 FIELD between VALUE1 and Field2 FIELD between Field2 and VALUE1 FIELD between Field2 and Field3

It also was discarded of the to-do list as now is much easier to write predicates. If you want VALUE BETWEEN FIELD 1 AND FIELD 2, you have to use two combined predicates:

filter.Add(date1 >= OrderFields.Date1 AND date2 <= OrderFields.Date2);

I tried the following:

filter.Add(effectiveFromDateTime >= CurvePointFields.EffectiveFromDateTime AND effectiveToDateTime <= CurvePointFields.EffectiveToDateTime);

I got the error:

Operator '>=' cannot be applied to operands of type 'System.DateTime' and 'ORMSupportClasses.EntityField'

Am I missing something? I took your code example as verbatim... Sorry for the newby question but I guess I'm still not understanding.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Feb-2012 05:00:44   

Sorry, I meant:

filter.Add(CurvePointFields.EffectiveFromDateTime <= effectiveFromDateTime AND  CurvePointFields.EffectiveToDateTime >= effectiveToDateTime);

IEntityFieldCore is always the left side.

David Elizondo | LLBLGen Support Team