This article is a mirror article of machine translation, please click here to jump to the original article.

View: 47694|Reply: 2

[Source] ef displays the generated SQL statements

[Copy link]
Posted on 6/27/2017 3:34:53 PM | | | |


Published on 2017/6/27 15:28:24 +08:00
The connection is open

SELECT Count(*)
FROM INFORMATION_SCHEMA. TABLES AS t
WHERE t.TABLE_SCHEMA + '.' + t.TABLE_NAME IN ('dbo. Tab1','dbo. Tab2')
    OR t.TABLE_NAME = 'EdmMetadata'


-- On 6/27/2017 15:28:24 +08:00
execute
-- Completed in 12 milliseconds with a result: 2



Published on 2017/6/27 15:28:24 +08:00
Closed the connection
Published on 2017/6/27 15:28:25 +08:00
The connection is open
SELECT
    [GroupBy1]. [A1] AS [C1]
    FROM ( SELECT
        COUNT(1) AS [A1]
        FROM [dbo]. [__MigrationHistory] AS [Extent1]
        WHERE [Extent1]. [ContextKey] = @p__linq__0
    )  AS [GroupBy1]


-- p__linq__0: 'CodeFirstDemo.TestDb' (Type = String, Size = 4000)

-- On 2017/6/27 15:28:26 +08:00
execute
-- Completed in 4 milliseconds with the result: SqlDataReader



Uploaded on 2017/6/27 15:28:26 +08:00
Closed the connection
Uploaded on 2017/6/27 15:28:26 +08:00
The connection is open
SELECT TOP (1)
    [Project1]. [C1] AS [C1],
    [Project1]. [MigrationId] AS [MigrationId],
    [Project1]. [Model] AS [Model],
    [Project1]. [ProductVersion] AS [ProductVersion]
    FROM ( SELECT
        [Extent1]. [MigrationId] AS [MigrationId],
        [Extent1]. [Model] AS [Model],
        [Extent1]. [ProductVersion] AS [ProductVersion],
        1 AS [C1]
        FROM [dbo]. [__MigrationHistory] AS [Extent1]
        WHERE [Extent1]. [ContextKey] = @p__linq__0
    )  AS [Project1]
    ORDER BY [Project1]. [MigrationId] DESC


-- p__linq__0: 'CodeFirstDemo.TestDb' (Type = String, Size = 4000)

-- On 2017/6/27 15:28:26 +08:00
execute
-- Completed in 4 milliseconds with the result: SqlDataReader



Uploaded on 2017/6/27 15:28:26 +08:00
Closed the connection
Method 1:



Method 2:




(In EF 4.1, we can directly call DbQuery<>'s ToString() method to get the generated SQL.) )




Previous:Alibaba Cloud SMS Service sends promotional SMS messages in batches
Next:[A] MySql.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySql.Data.MySqlC...
 Landlord| Posted on 2/19/2021 1:36:54 PM |
EF Core Series 4 looks at the generated SQL statements
https://www.itsvse.com/thread-9564-1-1.html
 Landlord| Posted on 1/2/2025 12:10:54 PM |
[Actual combat]. NET/C# SQL query generator based on sqlkata
https://www.itsvse.com/thread-10370-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com