If you are reading this, welcome to LINQ. You won't regret it.
I hope you scoured
Scott Guthrie's blog for all the LINQy goodness it has. In terms of keeping your business rules for data together in your app, LINQ is a god send. Defining reams of stored procedures then hooking them all up in ADO.NET was getting tiresome.
Especially if your Update parameter changes would not be detected by a Table Adapter reconfigure no matter how many rebuilds and cleans you ran so you had to recreate from scratch and you forgot to note the extra queys first and crap VSS just cacked itself and the other dev just rebuilt his workstation so he doesn't have a copy and OH MY GOD THE URGE TO KILL IS RISING!!!
Now, a couple of tips for first timers. To help avoid random homicide.
First, what is the data type returned by a LINQ query? Well, given we have a SalesDataAccess namespace with a SalesRecord class sitting in a LINQ data context, we would do this:
Dim query As System.Linq.IQueryable(Of SalesDataAccess.SalesRecord) = From sr In ldsSales.SalesRecords Select Sales
That's it. IQueryable is the one. You've no idea how hard it was to figure that out with just intellisense and google. Or maybe my googling is lame.
If your result set is shaped, you'll need to create a Generic.List with the data types of your result set as items. Put your query in parentheses and use .ToList to make it happen.
Dim query AsGeneric.List(Of String, Integer, String) = (From sr In ldsSales.SalesRecords Select Name = Sales.Name, ID = Sales.ID, Store = Sales.StoreName).ToList
Another good tip is how to use the .Where function. Handy if you have to filter your query according to a list of controls that may or may not have filter options selected. After your query, write something like this for each filter option that has a value.
query = query.Where(Function(salerec As SalesDataAccess.SalesRecord) salerec.Company_Id = ddlCompany.SelectedValue)
So what's going on here? In the Where parameter, you actually define a boolean function that rows from the query will be passed into. If the row would return true from the function, it stays. Otherwise it goes. Obviously the parameter in the function is the same type as the rows in your query.
Easy when you know how, but I sacrificed a lot of hair to these two nuggets.
My cert books cannot come fast enough.