Cast EntityField

Posts   
 
    
Posts: 14
Joined: 10-Dec-2015
# Posted on: 28-Sep-2016 09:09:28   

Hi all! I'm use LLBLGen 4.2 and PostgreSQL 9.4. Self-Servicing I need to implement this part of query: "WHERE CAST(number AS character varying) LIKE '10%'" Number - bigint When I use : "new FieldLikePredicate(ProductFields.Number, $"{searchNumber}%")" It's throw exception: "An exception was caught during the execution of a retrieval query: 42883: operator does not exist: bigint ~~ character varying. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception." It is possible to implement? Thanks

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 28-Sep-2016 17:21:40   

If you are using QuerySpec, then use the ToString() Convert Function

If you are using the LLBLGen Low level APIs, then you need to set an expression to the field participating in the predicate, to call a database function (CAST) in your case. It's all explained here with examples: Calling a database function