How do you do fulltext search with Entity Framework Core?

asp.net-core c# entity-framework-core sql-server

Question

I have the following query:

SELECT Animals.name 
FROM Animals 
WHERE CONTAINS(*, 'feline AND black');

I am having trouble converting it to an Entity Framework Core query. I have a SQL Server with a catalog that has a few indexes.

I want to be able to use FREETEXT and CONTAINS to do a fulltext query on the tables. I cannot find the method in Entity Framework Core for fulltext search with CONTAINS.

1
3
10/5/2018 8:33:09 PM

Accepted Answer

This is possible as of EF Core 2.1. You have to add a using statement for Microsoft.EntityFrameworkCore but after that you can use it as shown below

var results = db.Widgets
    .Where(x => EF.Functions.FreeText(x.ColumnName, "search text"));
5
1/7/2019 10:14:54 PM


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