Where to find translated Linq to Entity query to Sql

后端 未结 3 847
臣服心动
臣服心动 2021-01-18 01:30

I want to get the translated Linq query programmatically and do some stuff with that Sql syntax.

Suppose this is my code:

public class MyApiControlle         


        
3条回答
  •  深忆病人
    2021-01-18 02:09

    another option if you are using Entity Framework 6 is use the new feature to logging whats is happen, you can get the t-sql and the query time:

    Logging and Intercepting Database Operations

    using (var context = new BlogContext()) 
    { 
        context.Database.Log = Console.Write; //here, you can write this info to a text file for example.
    
        // Your code here... 
    }
    

提交回复
热议问题