Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Full-text search in Linq with several words

13.07.2018 (👁186140)

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