首页 > 代码库 > LINQ

LINQ

var query =    from c in contact    where c.FirstName.StartsWith("S")    && c.LastName.StartsWith("A")    orderby c.LastName    select c;
var query =    contact.Where(c => c.FirstName.StartsWith("S")                        && c.LastName.StartsWith("K")).OrderBy(c => c.LastName);

 

var query =    from c in contact    where c.FirstName.StartsWith("S")    select new { c.FirstName, c.LastName, c.EmailAddress };
var query =    contact.Select(c => new    {        c.FirstName,        c.LastName,        c.EmailAddress    }).Where(c => c.FirstName.StartsWith("S"));