Like predicate on SQLVariant

Posts   
 
    
jspuij
User
Posts: 24
Joined: 22-Jan-2007
# Posted on: 15-Oct-2009 11:42:56   

We use a table that has SQL Variants in it in our DB model. For a number of records this field contains a string value. We would like to use the FieldLikePredicate on these records on the SQLVariant column. This creates an invalid query, because SQL Server doesn't like using the like predicate on variant columns without a cast to nvarchar.

Is there any way to get LLBLGen to emit this cast in the query?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 15-Oct-2009 13:32:24   

The CAST() is a dbFunction, so you may try to use DBFunctionCall to set the field ExpressionToApply.

eg. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=12122

for CAST(), your expresson shold look like:

myField.ExpressionToApply = New DbFunctionCall("CAST({0} AS AS NVARCHAR)", New Object() {CustomerFields.SomeField})