So I'm using LINQKIT found here
And I'm trying to create an expression on one of my columns, CID.
The predicate looks like this:
Dim cid As String = "11R"
Dim predicate = PredicateBuilder.[New](Of uv_Manifest).And(Function(x) x.CID = cid)
And it returns a predicate which looks like this:
{x => (CompareString(x.CID, value(FSVendor_RefactoredRepository.ManifestManager+_Closure$__2-0).$VB$Local_cid, False) == 0)}
This returns SQL which looks like this:
SELECT
[Extent1].[CID] AS [CID],
FROM (SELECT
[uv_Manifest].[CID] AS [CID],
FROM [dbo].[uv_Manifest] AS [uv_Manifest]) AS [Extent1]
WHERE ([Extent1].[CID] = @p__linq__0) OR (([Extent1].[CID] IS NULL) AND (@p__linq__0 IS NULL))
When I run this statement in visual studio it times out, whereas if I hardcode the predicate to be like this:
Dim predicate = PredicateBuilder.[New](Of uv_Manifest).And(Function(x) x.CID = "11R")
It works fine and gives me a predicate which looks like this:
{x => (CompareString(x.CID, "11R", False) == 0)}
And the SQL looks like this:
SELECT
[Extent1].[CID] AS [CID]
FROM (SELECT
[uv_Manifest].[CID] AS [CID]
FROM [dbo].[uv_Manifest] AS [uv_Manifest]) AS [Extent1]
WHERE '11R' = [Extent1].[CID]
And it executes fine.
Here is my line of LINQ:
Dim q = webDataContext.uv_Manifest.AsExpandable().Where(filters)
Why is it when I change the value to be hardcoded it works as expected but when I don't it doesn't create the correct SQL statement and how do I fix this?