Created
July 3, 2022 11:14
-
-
Save MahdiKarimipour/108452d2584229a54b66ca46d48da0a1 to your computer and use it in GitHub Desktop.
How to Run Full-Text Queries using C# and Entity Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IQueryable<Address> GetFullText( | |
Expression<Func<Address, string>> predicate, | |
string query, | |
int currentPage = 0, | |
int pageSize = 0) | |
{ | |
if (pageSize == 0) | |
{ | |
return Context.Addresses | |
.Where(e => EF.Functions.Contains(e.FullAddress, $"\"{query}\"")); | |
} | |
return Context.Addresses | |
.Where(e => EF.Functions.Contains(e.FullAddress, $"\"{query}\"")) | |
.Skip((currentPage - 1) * pageSize) | |
.Take(pageSize); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment