Finished Query Syntax vs. Method Syntax
parent
066f46a48c
commit
ea26766337
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
|
||||||
namespace Features
|
namespace Features
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,26 @@ namespace Features
|
||||||
{
|
{
|
||||||
Console.WriteLine(employee.Name);
|
Console.WriteLine(employee.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LINQ (Method syntax)
|
||||||
|
var query = developers.Where(e => e.Name.Length == 5)
|
||||||
|
.OrderBy(e => e.Name);
|
||||||
|
|
||||||
|
// LINQ (Query syntax)
|
||||||
|
var query2 = from developer in developers
|
||||||
|
where developer.Name.Length == 5
|
||||||
|
orderby developer.Name descending
|
||||||
|
select developer;
|
||||||
|
|
||||||
|
foreach (var employee in query)
|
||||||
|
{
|
||||||
|
Console.WriteLine(employee.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var employee in query2)
|
||||||
|
{
|
||||||
|
Console.WriteLine(employee.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue