Linq to sql doesn't put quotes around strings in where clause

I have a simple Linq to SQL query that pulls data with a where clause as a string. The result query does not place quotes around the string.

Example

string name = "John";
var query = from n in db.Names where n.Name == name select n;

result

.... WHERE ([t0]. [Name] = John) ....

The net is varchar (10) and the TNT is populated from a string variable (not named John; -).

The weird thing ... sometimes she does it and sometimes she doesn't!

Ideas?

+1


source to share


1 answer


Every instance I've seen in all of my LINQ to SQL uses parameterized queries, so I have no idea how you got this output. It should be larger in lines:

WHERE ([t0].[Name] = @p0)
--@p0 VARCHAR John

      



if you set context.log to console.out you can see all sql executables. I only offer this to make sure this is what is happening.

+1


source







All Articles