force blToolkit to insert parameters

454 Views Asked by At

I use BlToolkit and want it to do not use parameters in final compiled query.

EXAMPLE: The query it compiles :

--  Sql MsSql2005
-- DECLARE @p1 Int64
-- SET @p1 = 101671702

SELECT * FROM dbo.Table1 WHERE Id = @p1

but I want it to compile like this:

--  Sql MsSql2005

SELECT * FROM dbo.Table1 WHERE Id = 101671702

Any idea?

2

There are 2 best solutions below

1
Mladen Macanović On

BLToolkit only shows commented parameters when you get the compiled query through the debug info. If you open the SQL Server Profiler and see the query that is executing than these parameters are not there. So I think you're ok with the execution plan.

0
andri On

if you know exactly what SQL to execute, you should use SetCommand and then execute the SQL directly, something like this :

using (var db = new DbManager("DemoConnection")){
    var data = db
        .SetCommand("SELECT * FROM dbo.Table1 WHERE Id = 101671702")
        .ExecuteList<Table1>();
}