获得EntityFramework生成的SQL语句

ObjectQuery.ToTraceString 方法 ()

用法

int productID = 900;
using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    // Define the object query for the specific product.
    ObjectQuery<Product> productQuery =
        context.Products.Where("it.ProductID = @productID");
    productQuery.Parameters.Add(new ObjectParameter("productID", productID));

    // Write the store commands for the query.
    Console.WriteLine(productQuery.ToTraceString());
}
来自msdn


版权声明:本文为Hmillet原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。