Literal in select query instead of bind variables

Literal in select query instead of bind variables

Postby PavelTr » Mon 05 Aug 2013 15:13

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.
PavelTr
 
Posts: 5
Joined: Thu 13 Jun 2013 10:42

Re: Literal in select query instead of bind variables

Postby Shalex » Wed 07 Aug 2013 07:37

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)
Shalex
Devart Team
 
Posts: 7540
Joined: Thu 14 Aug 2008 12:44

Re: Literal in select query instead of bind variables

Postby PavelTr » Wed 07 Aug 2013 08:30

Thanks.
PavelTr
 
Posts: 5
Joined: Thu 13 Jun 2013 10:42


Return to dotConnect for Oracle