TX message asked the front of the SQL is how the page, read this article you will know.
Component can output executed SQL to facilitate viewing SQL generated statements for problems.
To output SQL by registering events
DbSession.Default.RegisterSqlLogger(database_OnLog);
private string sql;
void database_OnLog(string logMsg)
{
//保存执行的DbCommand (sql语句和参数)
sql += "<br />" + logMsg;
}
and then by executing
DbSession.Default.UnregisterSqlLogger (Database_onlog); To unregister the registered event.
Here is an example of asp.net
DbSession.Default.From<Products>()
.InnerJoin<Suppliers>(Suppliers._.SupplierID == Products._.SupplierID)
.Page(10, 2)
.Select(Products._.ProductID, Products._.ProductName)
.ToDataTable();
The SQL statement that executes the above statement output is as follows:
SELECT * FROM
( SELECT TOP 10 * FROM
( SELECT TOP 20 [Products].[ProductID],[Products].[ProductName]
FROM [Products]
INNER JOIN [Suppliers]
ON ([Suppliers].[SupplierID] = [Products].[SupplierID])
ORDER BY [Products].[ProductID] ASC) AS tempIntable
ORDER BY [ProductID] DESC) AS tempOuttable
ORDER BY [ProductID] ASC
One more.
Dbsession.default.from<products> (). Where (products._. CategoryID = 2). Tofirst ();
The resulting SQL statement is as follows
Text:
SELECT TOP 1 * FROM [Products] WHERE [Products].[CategoryID] = @ae2b9c6a112545e5b56fa6dc70f32ac1
Parameters:
@ae2b9c6a112545e5b56fa6dc70f32ac1[Int32] = 2
This component generated SQL statements can be at a glance, the output of SQL statements is also greatly facilitated debugging.
The next section describes the generation of whereclip (conditions).