views:

216

answers:

1

I have a simple Linq to SQL query that is pulling data with a where clause by a string. The result query doesn't put quotes around the string.

Example

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

the result is

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

Network is a varchar(10) and TNT was populated from a string variable (not called John ;-).

The strange thing is...sometimes it does this and sometimes it doesn't!

Ideas?

+1  A: 

Every instance i've seen in all my LINQ to SQL uses paramaterized queries so I have no idea how you got that output.. it should be more along the lines of:

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

if you set your context.log to console.out you can see all the sql executing.. I only suggest this to make sure that is what is happening.

Quintin Robinson