Giter Site home page Giter Site logo

fissoft.entityframework.fts's Introduction

Fissoft.EntityFramework.Fts

Full Text Search for Microsoft SQL Server with Entity Framework

NuGet Install

install from nuget Build status release CodeFactor

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.

    var text = FullTextSearchModelUtil.Contains("code");
    db.Tables.Where(c=>c.Fullname.Contains(text));
    var text = FullTextSearchModelUtil.FreeText("code ef");
    db.Tables.Where(c=>c.Fullname.Contains(text));
    var text = FullTextSearchModelUtil.ContainsAll("code ef");
    db.Tables.Where(c=>c.Name.Contains(text)); //c.Name could be any string property of model
    var text = FullTextSearchModelUtil.FreeTextAll("code ef");
    db.Tables.Where(c=>c.Name.Contains(text)); //c.Name could be any string property of model
    var text = FullTextSearchModelUtil.Contains("a b",true);
    var query = 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

var query = 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 package Microsoft.EntityFrameworkCore.SqlServer.

   using Microsoft.EntityFrameworkCore;
   var result = db.TestModel.Where(c => EF.Functions.FreeText(c.Text, "search"));

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

fissoft.entityframework.fts's People

Contributors

chsword avatar icnocop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.