如何:显示生成的 SQL (LINQ to SQL)

2025-05-07 19:34:59
推荐回答(1个)
回答(1):

您可以将此属性与查询、插入、更新和删除命令一起使用。SELECT [t0].[CustomerID], [t0].[CompanyName], [t0].[ContactName], [t0].[ContactTitle], [t0].[Address], [t0].[City], [t0].[Region], [t0].[PostalCode], [t0].[Country], [t0].[Phone], [t0].[Fax]FROM [dbo].[Customers] AS [t0]WHERE [t0].[City] = @p0-- @p0: Input String (Size = 6; Prec = 0; Scale = 0) [London]-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20810.0AROUTBSBEVCONSHEASTCNORTSSEVES Visual Basic db.Log = Console.Out Dim custQuery = _ From cust In db.Customers _ Where cust.City = "London" _ Select cust ForEach custObj In custQuery Console.WriteLine(custObj.CustomerID) Next C# db.Log = Console.Out; IQueryable custQuery = from cust in db.Customers where cust.City == "London" select cust; foreach(Customer custObj in custQuery) { Console.WriteLine(custObj.CustomerID); }