Entity Framework Goodness

I finally got around to the Entity Framework BETA 2, and I like it already. To play with this, you need these bits;

Entity Framework Beta 2:
http://www.microsoft.com/downloads/details.aspx?FamilyID=f1adc5d1-a42e-40a6-a68c-a42ee11186f7&displaylang=en

Tools, Aug 2007 CTP:
http://www.microsoft.com/downloads/details.aspx?FamilyId=09A36081-5ED1-4648-B995-6239D0B77CB5&displaylang=en

There is also a nice "Getting Started" piece on codeplex:

Getting Started:
http://www.codeplex.com/adonetsamples/Release/ProjectReleases.aspx?ReleaseId=7792

I decided to brave it and just roll a quickie on my own from the Northwind database. All you do is Add New Item / ADO.NET Entity Data Model, which gives you a wizard to choose what database objects you want modeled, and then you get a nice class diagram:

EntityDesignerDiagram

All your entity model code is built for you. So to say, get 10 products from the Products table via a nice little LINQ query:

// Get 10 products via Entity LINQ query
using (NorthwindModel.NorthwindEntities1 ent = new NorthwindEntities1())
{
Products[] prod = (NorthwindModel.Products[])
(from pr in ent.Products select pr).Take(10).ToArray();
GridView1.DataSource = prod;
GridView1.DataBind();
}


LINQ is extremely cool. As with any new technology, there is quite a learning curve, but it's really worth the effort. You can get into all kinds of complex LINQ queries and joins, the vocabulary and the syntax, especially combined with Lambda expressions, is outstanding. I've been working out of the Albaharis' book from O'Reilly, "C# 3.0 in a Nutshell", which has extensive reference-book type material on LINQ. They also have a free downloadable "LINQPAD" executable which i highly recommend.

Oh, and just for the sake of being concise: this is for Visual Studio 2008 - Orcas, NOT Visual Studio 2005.

Sweet!

Comments

  1. Anonymous11:17 AM

    You can download LINQpad here...

    http://www.albahari.com/linqpad.html

    ReplyDelete
  2. Anonymous8:33 AM

    I use your rss feeds on the igoogle. For the last two days, clicking on your link is taking me to a ad website with no time out or other alternate link on that ad page which can further lead me to the original link at your site??? (ad page starts with pheedo......) is that something you are doing purposely? I feel hijacked!!

    ReplyDelete
  3. I often experiment with ads and other features on my UnBlog. The correct feed url is now
    http://petesbloggerama.blogspot.com/feeds/posts/default?alt=rss

    --which serves the feed along with a small number of Pheedo ads.

    You will also find this url in the autodiscovery link rel tag, as well as the feed icon at the right top of the page.

    ReplyDelete

Post a Comment

Popular posts from this blog

ASP.NET: Loss of Session / Cookies with Frames

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX