- Notifications
You must be signed in to change notification settings - Fork15
Full Text Search for Microsoft SQL Server with Entity Framework
License
NotificationsYou must be signed in to change notification settings
fissoft/Fissoft.EntityFramework.Fts
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Full Text Search for Microsoft SQL Server with Entity Framework
PM>Install-Package Fissoft.EntityFramework.Fts
Execute init code on start or static ctor.
DbInterceptors.Init();
When search you can use the code following.
vartext=FullTextSearchModelUtil.Contains("code");db.Tables.Where(c=>c.Fullname.Contains(text));
vartext=FullTextSearchModelUtil.FreeText("code ef");db.Tables.Where(c=>c.Fullname.Contains(text));
vartext=FullTextSearchModelUtil.ContainsAll("code ef"); db.Tables.Where(c=>c.Name.Contains(text));//c.Name could be any string property of model
vartext=FullTextSearchModelUtil.FreeTextAll("code ef");db.Tables.Where(c=>c.Name.Contains(text));//c.Name could be any string property of model
vartext=FullTextSearchModelUtil.Contains("a b",true);varquery=db.TestModel.Where(c=>c.Name.Contains(text)).ToList();// Should return results that contain BOTH words. For the second param = false, should return records with either of the words
Multi field query
varquery=db.TestModel.Where(c=>(c.Name+c.Text).Contains(text)).ToList();
will generate the sql
SELECT [Extent1].[Id]AS [Id], [Extent1].[Text]AS [Text], [Extent1].[Name]AS [Name]FROM [dbo].[TestModels]AS [Extent1]WHERE CONTAINS(([Extent1].[Name] , [Extent1].[Text]),@p__linq__0);
http://www.entityframework.info/Home/FullTextSearch
In .NET core 2.1 you can use offical freetext method to search.
Install the packageMicrosoft.EntityFrameworkCore.SqlServer.
usingMicrosoft.EntityFrameworkCore;varresult=db.TestModel.Where(c=>EF.Functions.FreeText(c.Text,"search"));
About
Full Text Search for Microsoft SQL Server with Entity Framework
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.