views:

356

answers:

2

Is there any way to make NHibernate.Linq generate a like query on an integer field? The SQL that I want it to generate is:

select IntegerColumn 
from Table 
where IntegerColumn like '%StringValue%'

I've tried something like:

from entity in _session.Linq<Entity>
where entity.IntegerColumn.ToString().Contains(StringValue)
select entiry.IntegerColumn

This produces an ArgumentOutOfRange exception when it evaluates the query.

Does anyone have an idea how I can accomplish this?

Thanks, Nathan

A: 

I believe this is specific to NHibernate Linq.

In linq-to-sql this works no problem:

...
WHERE (CONVERT(NVarChar,[t0].[INTEGERFIELD])) LIKE @p0
-- @p0: Input NVarChar (Size = 3; Prec = 0; Scale = 0) [%1%]
Yannick M.
don't think he asked how it works in link2sql
mxmissile
Indeed, however by testing it with linq-to-sql he knows he's probably not doing anything wrong, and he should consult the nhibernate support forums.
Yannick M.
A: 

See this thread on nhusers

James L