Why does Entity Framework generate slow overengineered SQL?
问题 I have this code: DbSet<TableName> table = ...// stored reference var items = from n in table where n.Name.ToUpper().Contains(searchString.ToUpper().Trim()) select n; WriteToLog( items.ToString() ); The last line outputs the generated SQL. Here's what I get: SELECT [Extent1].[Name] AS [Name], // all the other columns follow FROM (SELECT [TableName].[Name] AS [Name], // all the other columns follow FROM [dbo].[TableName] AS [TableName]) AS [Extent1] WHERE ( CAST(CHARINDEX(LTRIM(RTRIM(UPPER(@p_