Reputation: 110
I have an application with Entity Framework and SQL Server running in production and I am running the SQL Server Profiler to identify slow SQLs to optimize the application. I have a complex scenario with N possibilities of filtering choices, so I use PredicateBuilder in order to build my filters.
So, I found a weird SQL that I don't know what is generating it:
SELECT
1 AS [C1],
CAST(NULL AS int) AS [C2],
CAST(NULL AS varchar(100)) AS [C3],
CAST(NULL AS varchar(1)) AS [C4],
CAST(NULL AS int) AS [C5],
CAST(NULL AS datetime) AS [C6]
FROM ( SELECT 1 AS X ) AS [SingleRowTable1]
WHERE 1 = 0
Any idea of what can cause this problem?
Upvotes: 1
Views: 112
Reputation: 542
The EF do it when you have a where statement something like this:
list.Contains(x.Value)
And the collection, "list" in this example, is empty. You probably have something like this.
Upvotes: 3