Page 1 of 1

Literal in select query instead of bind variables

Posted: Mon 05 Aug 2013 15:13
by PavelTr
I try simple linq query

var books = Context.Books
.Where(b => b.BookId == 1)
.ToList();

I see in dbmonitor that the sql is

SELECT
Extent1.BookId,
Extent1.Name_Rus,
Extent1.Name_Eng,
Extent1.Code_Rus,
Extent1.Code_Eng,
Extent1.AUTHOR
FROM Book Extent1
WHERE Extent1.BookId = 1

Why did not use the bind variable instead of literal in sql and how can i config devart to use bind variable in select query?

Thanks.

Re: Literal in select query instead of bind variables

Posted: Wed 07 Aug 2013 07:37
by Shalex
Please try the following query:

Code: Select all

int a = 1;
var books = Context.Books
.Where(b => b.BookId == a)
.ToList();
It will generate:

Code: Select all

SELECT
Extent1.BookId,
Extent1.Name_Rus,
Extent1.Name_Eng,
Extent1.Code_Rus,
Extent1.Code_Eng,
Extent1.AUTHOR
FROM Book Extent1
WHERE (Extent1.BookId = = :p__linq__0) AND (:p__linq__0 IS NOT NULL)

Re: Literal in select query instead of bind variables

Posted: Wed 07 Aug 2013 08:30
by PavelTr
Thanks.