Full-text search in Linq: connecting several words
Linq with multiple filters
When filtering for multiple fields or terms, you can use the where statement with the combinations || for OR and && for AND
where (project.HTML.Contains("linq") || project.Title.Contains("sap")) |
Example with OR link
Shows all records with linq in the field: HTML or records that use SAP in the HTML field
string sFilter = "wpf";
//--< Get Linq.Query >-- //*gets last 10 Projects with View_Sum var query = (from project in _dbContext.tbl_Projects join u in _dbContext.tbl_Users on project.IDOwner equals u.IDUser into user_and_projects
from un in user_and_projects.DefaultIfEmpty() join aspUser in _dbContext.Users on un.IDAspNetUser equals aspUser.Id into user_and_projects_and_aspUser from unAsp in user_and_projects_and_aspUser.DefaultIfEmpty()
where (project.HTML.Contains("linq") || project.Title.Contains("sap"))
orderby project.IDProject descending select new { project, unAsp.UserName }).Take(50); //--</ Get Linq.Query >--
|
Simple filter
A simple word filter and also for partial sequences such as "seq" for subsequences
where (project.HTML.Contains("linq"))
|
NOT:
What does not work directly in Asp.Net Core MVC Linq is the search with where contains (field, term)
//*not: where contains(project.HTML,"linq") |