fissoft / Fissoft.EntityFramework.Fts

Full Text Search for Microsoft SQL Server with Entity Framework
MIT License
59 stars 14 forks source link

FTS was not replaced on... #5

Closed d668 closed 7 years ago

d668 commented 7 years ago
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Exception: FTS was not replaced on: SELECT
    [Project10].[TotalLikes] AS [TotalLikes],
    [Project10].[Id] AS [Id],
    [Project10].[Title] AS [Title],
    [Project10].[Text] AS [Text],
    [Project10].[AttachedText] AS [AttachedText],
    [Project10].[Url] AS [Url],
    [Project10].[PrivacyScope] AS [PrivacyScope],
    [Project10].[CreatedOn] AS [CreatedOn],
    [Project10].[InsertedOn] AS [InsertedOn],
    [Project10].[AttachedUrl] AS [AttachedUrl],
    [Project10].[PassId] AS [PassId],
    [Project10].[PassedOn] AS [PassedOn],
    [Project10].[AvgLikesPerDay] AS [AvgLikesPerDay],
    [Project10].[MinAge] AS [MinAge],
    [Project10].[MaxAge] AS [MaxAge],
    [Project10].[Gender] AS [Gender],
    [Project10].[Urls] AS [Urls],
    [Project10].[ActorsNames] AS [ActorsNames],
    [Project10].[MediaTexts] AS [MediaTexts],
    [Project10].[Label_Id] AS [Label_Id]
    FROM ( SELECT
        [Extent1].[Id] AS [Id],
        [Extent1].[Title] AS [Title],
        [Extent1].[Text] AS [Text],
        [Extent1].[AttachedText] AS [AttachedText],
        [Extent1].[Url] AS [Url],
        [Extent1].[PrivacyScope] AS [PrivacyScope],
        [Extent1].[CreatedOn] AS [CreatedOn],
        [Extent1].[InsertedOn] AS [InsertedOn],
        [Extent1].[AttachedUrl] AS [AttachedUrl],
        [Extent1].[PassId] AS [PassId],
        [Extent1].[PassedOn] AS [PassedOn],
        [Extent1].[TotalLikes] AS [TotalLikes],
        [Extent1].[AvgLikesPerDay] AS [AvgLikesPerDay],
        [Extent1].[MinAge] AS [MinAge],
        [Extent1].[MaxAge] AS [MaxAge],
        [Extent1].[Gender] AS [Gender],
        [Extent1].[Urls] AS [Urls],
        [Extent1].[ActorsNames] AS [ActorsNames],
        [Extent1].[MediaTexts] AS [MediaTexts],
        [Extent1].[Label_Id] AS [Label_Id]
        FROM  [dbo].[Ads] AS [Extent1]
        LEFT OUTER JOIN [dbo].[Labels] AS [Extent2] ON [Extent1].[Label_Id] = [Extent2].[Id]
        WHERE ((@p__linq__0 IS NULL) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM  [dbo].[Encounters] AS [Extent3]
            INNER JOIN [dbo].[MyAppUsers] AS [Extent4] ON [Extent3].[MyAppUser_Id] = [Extent4].[Id]
            WHERE ([Extent3].[Ad_Id] = [Extent1].[Id]) AND ([Extent4].[Birthday] IS NOT NULL) AND ((DATEPART (year, [Extent4].[Birthday])) <= ((DATEPART (year, SysUtcDateTime())) - @p__linq__1))
        ))) AND ((@p__linq__2 IS NULL) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM  [dbo].[Encounters] AS [Extent5]
            INNER JOIN [dbo].[MyAppUsers] AS [Extent6] ON [Extent5].[MyAppUser_Id] = [Extent6].[Id]
            WHERE ([Extent5].[Ad_Id] = [Extent1].[Id]) AND ([Extent6].[Birthday] IS NOT NULL) AND ((DATEPART (year, [Extent6].[Birthday])) >= ((DATEPART (year, SysUtcDateTime())) - @p__linq__3))
        ))) AND ((@p__linq__4 IS NULL) OR (( CAST(LEN(@p__linq__4) AS int)) = 0) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM  [dbo].[Encounters] AS [Extent7]
            LEFT OUTER JOIN [dbo].[MyAppUsers] AS [Extent8] ON [Extent7].[MyAppUser_Id] = [Extent8].[Id]
            WHERE ([Extent7].[Ad_Id] = [Extent1].[Id]) AND (([Extent8].[Gender] = @p__linq__5) OR (([Extent8].[Gender] IS NULL) AND (@p__linq__5 IS NULL)))
        ))) AND ((@p__linq__6 IS NULL) OR ([Extent1].[AvgLikesPerDay] > @p__linq__7)) AND ((@p__linq__8 IS NULL) OR ([Extent1].[TotalLikes] > @p__linq__9)) AND ((@p__linq__10 IS NULL) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM  [dbo].[Encounters] AS [Extent9]
            LEFT OUTER JOIN [dbo].[MyAppUsers] AS [Extent10] ON [Extent9].[MyAppUser_Id] = [Extent10].[Id]
            WHERE ([Extent9].[Ad_Id] = [Extent1].[Id]) AND (([Extent10].[Country] = @p__linq__11) OR (([Extent10].[Country] IS NULL) AND (@p__linq__11 IS NULL)))
        ))) AND ((@p__linq__12 IS NULL) OR ([Extent2].[LabelName] = @p__linq__13) OR (([Extent2].[LabelName] IS NULL) AND (@p__linq__13 IS NULL))) AND ((@p__linq__14 IS NULL) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM [dbo].[AdActors] AS [Extent11]
            WHERE ([Extent1].[Id] = [Extent11].[Ad_Id]) AND ([Extent11].[Actor_Id] = @p__linq__15)
        ))) AND ((@p__linq__16 IS NULL) OR ((N'video' = @p__linq__17) AND ( EXISTS (SELECT
            1 AS [C1]
            FROM [dbo].[Media] AS [Extent12]
            WHERE ([Extent1].[Id] = [Extent12].[Ad_Id]) AND (([Extent12].[Type] = @p__linq__18) OR (([Extent12].[Type] IS NULL) AND (@p__linq__18 IS NULL)))
        ))) OR (( NOT ((N'video' = @p__linq__19) AND (@p__linq__19 IS NOT NULL))) AND ( NOT EXISTS (SELECT
            1 AS [C1]
            FROM [dbo].[Media] AS [Extent13]
            WHERE ([Extent1].[Id] = [Extent13].[Ad_Id]) AND ((N'video' = [Extent13].[Type]) OR (CASE WHEN ( NOT ((N'video' = [Extent13].[Type]) AND ([Extent13].[Type] IS NOT NULL))) THEN cast(1 as bit) WHEN (N'video' = [Extent13].[Type]) THEN cast(0 as bit) END IS NULL))
        )))) AND ((@p__linq__20 IS NULL) OR ((@p__linq__21 IS NULL) AND (([Extent1].[Text] LIKE @p__linq__22 ESCAPE N'~') OR ([Extent1].[AttachedText] LIKE @p__linq__23 ESCAPE N'~') OR ([Extent1].[MediaTexts] LIKE @p__linq__24 ESCAPE N'~') OR ([Extent1].[Urls] LIKE @p__linq__25 ESCAPE N'~') OR ([Extent1].[ActorsNames] LIKE @p__linq__26 ESCAPE N'~'))) OR ((N'url' = @p__linq__27) AND ([Extent1].[Urls] LIKE @p__linq__28 ESCAPE N'~')) OR ((N'advertiser' = @p__linq__29) AND ([Extent1].[ActorsNames] LIKE @p__linq__30 ESCAPE N'~')) OR ((N'text' = @p__linq__31) AND (([Extent1].[Text] LIKE @p__linq__32 ESCAPE N'~') OR ([Extent1].[AttachedText] LIKE @p__linq__33 ESCAPE N'~') OR ([Extent1].[MediaTexts] LIKE @p__linq__34 ESCAPE N'~'))) OR ((N'comments' = @p__linq__35) AND ( EXISTS (SELECT
            1 AS [C1]
            FROM [dbo].[Comments] AS [Extent14]
            WHERE ([Extent1].[Id] = [Extent14].[Ad_Id]) AND (([Extent14].[Text] LIKE @p__linq__36 ESCAPE N'~') OR ([Extent14].[MyAppUserName] LIKE @p__linq__37 ESCAPE N'~'))
        )))) AND ((@p__linq__38 IS NULL) OR ( EXISTS (SELECT
            1 AS [C1]
            FROM [dbo].[Snapshots] AS [Extent15]
            WHERE ([Extent1].[Id] = [Extent15].[Ad_Id]) AND ([Extent15].[TakenOn] >= @p__linq__39)
        )))
    )  AS [Project10]
    ORDER BY [Project10].[CreatedOn] DESC
    OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
chsword commented 7 years ago

Can you submit your test case

d668 commented 7 years ago

Ok so here is a test case: run

var text = File.ReadAllText("sql.txt");
var matches = Regex.Matches(text, @"\[(\w*)\].\[(\w*)\]\s*LIKE\s*@p__linq__20\s?(?:ESCAPE N?'~')");

against attached SQL and matches doesn't have anything

sql.txt

chsword commented 7 years ago

In yout SQL ((@plinq20 IS NULL) OR ((@plinq21 IS NULL) AND (([Extent1].[Text] LIKE @plinq22 ESCAPE N'~')

There is no content @"[(\w)].[(\w)]\sLIKE\s@plinq20\s?(?:ESCAPE N?'~')") like .

Will you show your C# query?

chsword commented 7 years ago

May be try

dbContext.Configuration.UseDatabaseNullSemantics = true;

will clean x = null