csharp linq mselect

Code Example - csharp linq mselect

                
                        var users = new List<Users>()
var names = users.Select(xx=> xx.Name);
                    
                
 

linq where

                        
                                // The LINQ Where can be used to filter in a collection.
// It will return a Enumerable that contains all of the matching elements

var names = new List<string>() {"John", "Jane", "William"};

//I use ToLower to get any name that contains a J, Capital or not.
var namesWithJ = names.Where(n => n.ToLower().Contains("j"));

//Returns IEnumerable<string> that contains ["John", "Jane"]
                            
                        
 

linq query select where csharp

                        
                                var queryLondonCustomers = from cust in customers
                           where cust.City == "London"
                           select cust;
                            
                        
 

linq csharp where condition

                        
                                var query = MemberTable.Where(x=>x.sex.Equals(Sex))

if (members != null)
     query = query.Where(x=>members.Contains(x.membercode))

//use your query
query.ToList();
                            
                        
 

where in linq

                        
                                dataSource.StateList.Where(s => countryCodes.Contains(s.CountryCode))
                            
                        
 

linq where csharp

                        
                                linq in c#
                            
                        
 

csharp linq select from object list

                        
                                // this will return the first correct answer,
// or throw an exception if there are no correct answers
var correct = answers.First(a => a.Correct); 

// this will return the first correct answer, 
// or null if there are no correct answers
var correct = answers.FirstOrDefault(a => a.Correct); 

// this will return a list containing all answers which are correct,
// or an empty list if there are no correct answers
var allCorrect = answers.Where(a => a.Correct).ToList();
                            
                        
 

csharp linq list select

                        
                                List<Model> newList = list.Where(m => m.application == "applicationname")
    .Select(m => new Model { 
        application = m.application, 
        users = m.users.Where(u => u.surname == "surname").ToList() 
    }).ToList();