Skip to content

devlev/Devlev.EntityFramework.Fts

Repository files navigation

Devlev.EntityFramework.Fts

Full-Text Search in ADO.NET Entity Framework 6 with support LINQ.

How to use it?

  1. Download this source and build all project
  2. Add DLL Devlev.EntityFramework.Fts.dll to your project
  3. Create utility table FTS_Int
public partial class FTS_Int
{
    public int Key { get; set; }
    public int Rank { get; set; }
    public string Query { get; set; }
}
  1. Add table FTS_Int to your .edmx file;
  2. Add using Devlev.EntityFramework.Fts;
  3. See examples!

Examples

string queryText = FtsSearch.Query(
    dbContext: db,
    ftsEnum: FtsEnum.CONTAINS,
    tableQuery: typeof(Article),
    tableFts: typeof(FTS_Int),
    search: "text");

var queryFts = db.FTS_Int.Where(n => n.Query.Contains(queryText));

var query = db.Article
    .Where(n => n.Active)
    .Join(queryFts, article => article.Id, fts => fts.Key, (article, fts) => new
    {
        article,
        fts.Rank,
    })
    .OrderByDescending(n => n.Rank)
    .Take(10)
    .Select(n => n.article);

var result = FtsSearch.Execute(() => query.ToList());

Code Samples Async

// ...
var result = await FtsSearch.ExecuteAsync(async () => await query.ToListAsync());

Log

FtsSearch.Log = value => Console.WriteLine(value);

License

MIT licensed

About

Devlev.EntityFramework.Fts - Full-Text Search in ADO.NET Entity Framework 6 with support LINQ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages