Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Full Text Search for Microsoft SQL Server with Entity Framework

License

NotificationsYou must be signed in to change notification settings

fissoft/Fissoft.EntityFramework.Fts

Full Text Search for Microsoft SQL Server with Entity Framework

NuGet Install

install from nugetBuild statusreleaseCodeFactor

PM>Install-Package Fissoft.EntityFramework.Fts

Demo

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);

Reference:

http://www.entityframework.info/Home/FullTextSearch

About .NET Core

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"));

EF.Docs# Use FreeText( and soon Contains )functions

About

Full Text Search for Microsoft SQL Server with Entity Framework

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp