Where to find translated Linq to Entity query to Sql

后端 未结 3 844
臣服心动
臣服心动 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:01

    I think these posts may help you:

    1) How to view LINQ Generated SQL statements?

    2) How do I view the SQL generated by the Entity Framework?

    Couple of examples (from the above):

    var sql = ((System.Data.Objects.ObjectQuery)objs).ToTraceString();
    var sql = objs.ToString();
    

    Documentation on .ToTraceString() can be found here:

    MSDN trace string documentation

提交回复
热议问题