2

I'm trying to pass " 5.[0-9]" string to Linq Contains(),

var qry = (from b in db.X where b.XRef.Contains(" 5.[0-9]" ) 
           select b).ToList();

at SQL profiler the query is generated in this format

exec sp_executesql N'SELECT 
*FROM [dbo].[X] AS [Extent1]
WHERE ([Extent1].[XRef] LIKE @p__linq__1 ESCAPE N''~'')',N'@p__linq__1 nvarchar(4000)',@p__linq__1=N'% 5.~[0-9]%'

It generates an tilde "~[" in front of left square bracket, which is not correct. The SQL I am trying to generate is " Select * from X where Xref like '% 5.[0-9]%'"

Any suggestion how to solve this?

MethodMan
  • 18,625
  • 6
  • 34
  • 52
KDon
  • 21
  • 1

0 Answers0