FreeText in EF2.1: The 'FreeText' method is not supported because the query has switched to client-evaluation.

asp.net-core-2.1 c# entity-framework-core

Question

I'm trying to do simple fulltext search:

var dbquery = _dbContext.Contents
   .Where(c => EF.Functions.FreeText("Content", "a"));

var result = dbQuery.ToList();

but I'm getting:

InvalidOperationException: The 'FreeText' method is not supported because the query has switched to client-evaluation. Inspect the log to determine which query expressions are triggering client-evaluation.

Maybe it is important to note, that I'm using inheritance:

public class MyDbContext : DbContext
{
    public DbSet<ForumThread> ForumThreads { get; set; }
    public DbSet<ForumPost> ForumPosts { get; set; }

    public DbSet<ContentBase> Contents { get; set; }
 }

public abstract class ContentBase
{
    public Guid Id { get; set; }
    public string Content { get; set; }
}

public class GenericContent : ContentBase
{        
    public virtual string Title { get; set; }
    public virtual ICollection<Tag> Tags { get; set; } = new List<Tag>();
}

public class ForumThread : GenericContent {}

public class ForumPost : ContentBase
{
    public ForumThread Thread { get; set; }
}
1
1
9/13/2018 8:44:53 AM

Popular Answer

Alternative way:

var dbquery = _dbContext.Contents
    .Where(c => EF.Functions.FreeText(EF.Property<string>(c, "Content"), "a"));
0
10/21/2019 7:15:22 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow