LINQ to SQL: ExecuteQuery not working when performing a parameterized query.
Posted
by ajbeaven
on Stack Overflow
See other posts from Stack Overflow
or by ajbeaven
Published on 2010-05-27T04:44:36Z
Indexed on
2010/05/27
4:51 UTC
Read the original article
Hit count: 324
linq-to-sql
|parameterized-query
I have a weird problem with ExecuteQuery in that it isn't working when performing a parameterized query.
The following returns 1 record:
db.ExecuteQuery<Member>(@"SELECT *
FROM Member
INNER JOIN aspnet_Users ON Member.user_id = aspnet_Users.UserId
WHERE [aspnet_Users].[UserName] = 'Marina2'");
However, the parameterized version returns no results:
db.ExecuteQuery<Member>(@"SELECT *
FROM Member
INNER JOIN aspnet_Users ON Member.user_id = aspnet_Users.UserId
WHERE [aspnet_Users].[UserName] = '{0}'", "Marina2");
What am I doing wrong?
© Stack Overflow or respective owner