Like and nvarchar (with no length)

Posts   
 
    
yowl
User
Posts: 266
Joined: 11-Feb-2008
# Posted on: 07-Jul-2017 18:35:21   

LLBLGen Designer 5.1 (5.1.3) RTM LLBLGen Rutime 5.1.3.0 SQL Server version Microsoft SQL Server 2014 (SP2-GDR) (KB3194714) - 12.0.5203.0 (X64) Sep 23 2016 18:13:56 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 15063: ) (Hypervisor)

Hi,

Small thing really to do with the tracing:

<add name="SqlServerDQE" value="3" />

I build up a predicate in code, part of which is

filter = ((EntityField2)field % ("%" + criteria.Text + "%")); //SQL like

This goes on to generate the trace SQL which starts with

DECLARE @p1 NVarChar

Note that there is no length specified on the Nvarchar so it gets a default length which is 1, where as the field actually has a length of 50 and is set to something longer than one:

SET @p1='%VIT011-0517%'

The actual SQL executed is fine and has the length specified so there's no real problem, its just that when you cut and paste the trace output into SQL it doesn't do the same thing. Any chance you can add the length to the tracing?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Jul-2017 09:26:12   

What if you add ... ?

<add name="SqlServerDQE" value="4" />
<add name="ORMPlainSQLQueryExecution" value="4" />
David Elizondo | LLBLGen Support Team