Reputation: 27360
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; }
}
Upvotes: 3
Views: 2063
Reputation: 106
Alternative way:
var dbquery = _dbContext.Contents
.Where(c => EF.Functions.FreeText(EF.Property<string>(c, "Content"), "a"));
Upvotes: 2