FieldCompareRangePredicate with no values throw an exception

Posts   
 
    
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 11-Dec-2007 15:19:16   

v2.0: Why does FieldCompareRangePredicate with no values throw an exception? IMO it should be legal not to pass any value - in this case no entities would be filtered (_and not as I wrote fetched_).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 12-Dec-2007 10:33:40   

Because it will result in a field IN () query, so that's invalid.

Frans Bouma | Lead developer LLBLGen Pro
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Dec-2007 11:50:11   

Otis wrote:

Because it will result in a field IN () query, so that's invalid.

In database query it would. But in inmemory filtering it wouldn't - it should work by returning no entities, shouldn't it? Sorry for being vague before.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 12-Dec-2007 19:25:08   

Hmm. So specifying 'true' for negate on an empty range would mean all entities are returned?

It's an edge case which has a point. Changing it though will mean a behavior change. I don't expect a lot of people to report about this though, but just in case...

Anyway, just curious: why do you use the filter if the range is empty? Why not ignore it?

Frans Bouma | Lead developer LLBLGen Pro
mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 12-Dec-2007 23:47:15   

Otis wrote:

Hmm. So specifying 'true' for negate on an empty range would mean all entities are returned?

It's an edge case which has a point. Changing it though will mean a behavior change. I don't expect a lot of people to report about this though, but just in case...

Anyway, just curious: why do you use the filter if the range is empty? Why not ignore it?

I don't know in advance the range. I have to create a list of IDs that match some criteria (I do a loop through all entities - can't do it using .Filter property). So, if none matches then I should display an empty view, where user can still add entities (through grid). Or perhaps is there an other way to filter EntityView2<> using code?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 13-Dec-2007 11:36:09   

mihies wrote:

Otis wrote:

Hmm. So specifying 'true' for negate on an empty range would mean all entities are returned?

It's an edge case which has a point. Changing it though will mean a behavior change. I don't expect a lot of people to report about this though, but just in case...

Anyway, just curious: why do you use the filter if the range is empty? Why not ignore it?

I don't know in advance the range. I have to create a list of IDs that match some criteria (I do a loop through all entities - can't do it using .Filter property). So, if none matches then I should display an empty view, where user can still add entities (through grid). Or perhaps is there an other way to filter EntityView2<> using code?

Ah I see. I think we all got confused by the thing that 'no range' should mean NO entities matching the filter, I was locked into the thought: 'no range' means EVERYTHING matches, as there's nothing there to filter with. In the latter case, you can simply not using the filter, but in your case you have a range of id's you want to see, and an empty range should mean no entities to see, which isn't possible at the moment.

Removing the exception should fix it. I'll remove the exception.

(edit) Attached.

Frans Bouma | Lead developer LLBLGen Pro