Cast in Where Clause

Posts   
 
    
Sascha
User
Posts: 8
Joined: 12-Feb-2007
# Posted on: 24-Jul-2008 11:12:13   

Hi, I'm trying to filter an EntityView with a FieldLikePredicate. My problem is the type of the field to filter (int).

In SQL I would solve this problem: ... WHERE CAST(Id as nvarchar(10)) like '25%'

I want all Ids beginning with 25

How do solve this problem?

Greetings from Germany

Sascha

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 24-Jul-2008 11:26:47   

You will need to use a "database function call" as an expression set to the entityfield used in the predicate.

Please check Using a function call in a predicate

Sascha
User
Posts: 8
Joined: 12-Feb-2007
# Posted on: 24-Jul-2008 11:59:36   

Thanks for your reply. I can't use a "database function call", because I'm working with an EntityView. There is no new database-fetch possible.

Sascha

arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 24-Jul-2008 13:05:39   

For in memory filters you can provide a delegate that does what ever you want in deciding wether the particular entity passes or fails.

Sascha
User
Posts: 8
Joined: 12-Feb-2007
# Posted on: 24-Jul-2008 13:11:43   

arschr wrote:

can you use division? for example: x/10 = 25 or x/100 = 25 etc.

or place a work field in the entity that converts the int to string?

Thanks for your answer. - I can't use division (divisor is unknown) - the work field seems to be a good idea :-)

Sascha

Sascha
User
Posts: 8
Joined: 12-Feb-2007
# Posted on: 24-Jul-2008 16:10:44   

It is just a workaround. I hope there is a better solution for this problem. sunglasses

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 24-Jul-2008 17:03:46   

Sascha wrote:

It is just a workaround. I hope there is a better solution for this problem. sunglasses

Use a DelegatePredicate

Frans Bouma | Lead developer LLBLGen Pro
Sascha
User
Posts: 8
Joined: 12-Feb-2007
# Posted on: 24-Jul-2008 17:17:50   

Wow!!! This works great. smile Thanks a lot Otis.

Sascha