Answers for "c# linq select"

C#
2

c# 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();
Posted by: Guest on March-18-2020
1

linq query select where c#

var queryLondonCustomers = from cust in customers
                           where cust.City == "London"
                           select cust;
Posted by: Guest on November-05-2020
1

linq select

IEnumerable<SelectListItem> stores =
        from store in database.Stores
        where store.CompanyID == curCompany.ID
        select new SelectListItem { Value = store.Name, Text = store.ID };
Posted by: Guest on July-11-2021
1

c# 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();
Posted by: Guest on February-01-2021
0

linq query in c# to select all

var from cars in lstCars select cars
Posted by: Guest on August-09-2021

C# Answers by Framework

Browse Popular Code Answers by Language