Horje
how to create more accurate searching c# Code Example
how to create more accurate searching c#
var keywords = new [] {"Sergey", "Berezovskiy"};

var users = from u in context.Users
            let match = (keywords.Contains(u.FirstName) ? 1 : 0) +
                        (keywords.Contains(u.LastName) ? 1 : 0) +
                        (keywords.Contains(u.MiddleName) ? 1 : 0)
            where match > 0
            orderby match descending, 
                    u.LastName, u.FirstName
            select u;

var methodChain = context.Users
                .Select(u => new
                {
                    u,
                    match = (keywords.Contains(u.FirstName) ? 1 : 0) +
                        	(keywords.Contains(u.LastName) ? 1 : 0) +
                        	(keywords.Contains(u.MiddleName) ? 1 : 0)
                })
                .Where(t => t.match > 0)
                .OrderByDescending(t => t.match)
  				.ThenBy(t.u.LastName)
  				.ThenBy(t.u.FirstName)
                .Select(t => t.p);




Csharp

Related
switch case with 2 variables c# Code Example switch case with 2 variables c# Code Example
In ASP.NET Core how check if request is local Code Example In ASP.NET Core how check if request is local Code Example
c# object to xmldocument Code Example c# object to xmldocument Code Example
autoclicker for yes/no in c# indicator Code Example autoclicker for yes/no in c# indicator Code Example
open aspx page c# Code Example open aspx page c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9