Performing a simple query.
Using Microsoft’s new elegant syntax or subset of the .NET framework that looks like it might be replacing ADO.NET, I will illustrate how to perform a simple query.
This new syntax is much less bulky than executing the same query using ADO.NET commands.
First, I’ll begin by creating a class to represent test Order records.
With my new class ready, I’ll instantiate a series of fake orders similar to what you might see in a live system.
Now that I’ve got a collection of test orders, I’ll perform a simple query using Linq to return all orders.
The previous query populated a Linq object with all orders from my test data source.
I will now run a simple application to iterate through the collection while displaying each order’s data.
As you can see, all test orders have written to the screen.