Welcome to Bourgan Systems Sign in | Join | Help
Visual Studio '08 Goodness

I recently attended the Heroes Happen {Here} launch event for Visual Studio 2008, SQL Server 2008, and Windows Server 2008 and thought I might start my blogging by sharing some good stuff that we developers now have available to us with VS08. 

LINQ

I'm sure you've read a lot of information already about LINQ and maybe even played with it yourself.  So far, my experience with LINQ has been reading blogs and promotional information about it and it seems that the common focus is on LINQ to SQL or some other data-oriented source such as XML.  While that is all good and well, I wasn't very excited about it because I'm a firm believer in stored procedures for working with data in a database.  Your personal style may differ, but I personally prefer to use stored procedures over any kind of in-code SQL statements.  What I did like when I saw it at the launch event was LINQ to Objects.

LINQ to Objects

LINQ to Objects hasn't been as highly publicized and thus I may have missed it, but basically you can perform a LINQ query on a collection of entity objects.  This can be useful if you want to select a subset of your collection for use as a DataSource in data binding a control.  Here is an example of what I mean:

   1:  List<DemoEntity> entities = SomeDataObject.GetAll();
   2:  var filteredEntities = from entity in entities
   3:                        where entity.Field3 == true
   4:                        select entity;   
   5:   
   6:  GridView1.DataSource = filteredEntities;
   7:  GridView1.DataBind();
 

As you can see in the sample code, we're selecting a subset of the List<> of DemoEntity objects.  This could be used for a filter on the data grid in the example above, or you can come up with your own scenario.  Just as simply, you could provide a way for users to sort data by changing the LINQ query to:

   1:  var sortedEntities = from entity in entities
   2:                       orderby entity.Field2
   3:                       select entity;

From playing with LINQ a bit, I've decided that I need to go down the path of learning more about it.  Anyone had good experiences with LINQ?  How about bad experiences?  Leave a comment and let me know how it's working out for you.

Posted: Tuesday, March 11, 2008 12:31 AM by MBourland

Comments

Random Techy-ness said:

Since my first foray into code snippets inside of a blog post didn't go so well, here's another attempt

# March 11, 2008 9:35 AM
New Comments to this post are disabled