Sunday, October 25, 2009

LINQ and Entity Framework Posts for 10/19/2009+

Note: This post is updated weekly or more frequently, depending on the availability of new articles.

Entity Framework and Entity Data Model (EF/EDM)

Julie Lerman created a Screencast – What’s new in the Entity Data Model Designer in VS2010 and posted it on 10/23/2009. Here’s her description and a link to view it:

I have created a screencast showing some of the best new features of the new Entity Data Model Designer. This is using the new Beta 2 version of Visual Studio 2010.

The screencast is about 20 minutes long.

This is not designed to be an introduction to building models. Rather, it specifically highlights (and demonstrates) the improvements, so should be of great interest to those who have been using the designer or possibly looked at in the past and said “meh” and walked away.

In the video, I go over:

  • EDM Wizard naming the entities with proper plural and singular names and a few minor issues
  • Impact that Foreign Keys has on Association Mappings
  • Creating complex types
  • Mapping Insert/Update/Delete Stored procs to entities with Complex Types
  • Creating functions from Stored Procedures that return results which do not map to an entity
  • Quick look at Model First Design

There are more new goodies in the designer, just couldn’t cover them all in one shot!

You can also find the screencast at

Gil Fink offers on 10/21/2009 his ADO.NET Entity Framework Session Slide Deck:

Two days ago I had a half day session at Microsoft [Israel] about Entity Framework. The agenda was as follows:

  • Entity Framework Introduction
  • Exploring the Entity Data Model
  • Querying and Manipulating Entity Data Models
  • Customizing Entity Data Models Examples
  • EF4

As I promised the slide deck and demos can be downloaded from here. I want to thank the attendees of the session and I hope you had great time like I did.

Also, I’m sorry for the late publishing but it was caused by technical problems
to upload the files into the blog’s server. Instead I put it in my Skydrive.

P.S – in order to use the demos you need to restore the added database
backup and replace all the connection strings in the demos to point to
the database you restored.

Jeffrey Schwartz reviews Entity Framework’s speckled history in his EF4 Beta 2 Arrives with New Features article for 1105 Media’s Data Driver column of 10/21/2009:

The big news for .NET developers this week is the release of beta 2 of Visual Studio 2010 and the .NET Framework 4, which became generally available today (see VS2010 and .NET 4 Beta 2 Go Live). For developers of data-driven applications, beta 2 included some major improvements to the ADO.NET Entity Framework, Microsoft's new interface for providing access to apps using object-relational modeling (ORM) rather than programming directly against relational schema.

First released with the Visual Studio 2008 and the .NET Framework 3.5 SP1, the Entity Framework has become a polarizing issue among database developers. As covered extensively, the Entity Framework has been a godsend to many programmers who welcome the move to model-driven development.

However it has also been much maligned by those who prefer the tried-and-true ADO.NET data access mechanism or those who feel that there are better object-relational mapping technologies than Microsoft has to offer such as the Nhybernate or Spring.NET.

Nonetheless Microsoft's Entity Framework stands out in another unique way: it is part of Visual Studio and the .NET Framework. And like it or not, it's here to stay. …

Gil Fink’s Calling User-Defined Functions (UDFs) in Entity Framework post of 10/20/2009 describes his response to a forum question:

Yesterday I answered a question in Entity Framework forum in regard of how to use User-Defined Functions (UDFs) in Entity Framework. This post holds the answer.

The Problem

I have a UDF in my database that I want to use with Entity Framework. When you use the Entity Data Model Wizard you can surface the function in the SSDL. When you will try map the created function element to a FunctionImport you’ll get the following exception: ”Error 2054: A FunctionImport is mapped to a storage function 'MyModel.Store.FunctionName that can be composed. Only stored procedure functions may be mapped.”
So how can we use the UDF?

Gill provides the answer.

Matheiu Mezil’s Entity Framework: the productivity way post of 10/20/2009 details gaining productivity with T4 templates:

One of the best points with Entity Framework is the developer productivity gain. If you associate EF with the T4 template code generation, this gain explodes. Imagine that we want a WCF service which exposes some data. For each entity type, you probably want a Get method which returns the entities, perhaps another Get which takes the entity id as parameter and which returns the entity with its relationships, a Add, a Update, perhaps a Delete.

EF allows an important productivity gain for the entities development and their use. However, in our case, to code to write is almost the same for each entity type. It means that it’s time to use the T4 template.

In all T4 samples I studied, this great template is used only for the entity generation. We will try here to go ahead. …

Kati Iceva’s and Noam Ben-Ami’s New features in Entity Framework impacting providers post of 10/22/2009 warns:

Providers for Entity Framework 3.5 will work unmodified against Entity Framework 4.0. Also, most of the features and improvements introduced in Entity Framework 4.0 will just work against an Entity Framework 3.5 provider. However, there are several features that require provider changes to be enabled. Below is a list of these features along with short description of the changes required to enable them.

New features in Entity Framework Runtime impacting providers

  • New EDM (Canonical) Functions
  • Date/Time functions
  • Math Functions
  • Aggregate functions
  • String functions

Considerations for Implementing New Features

Exposing provider functions in LINQ To Entities ()

  • Which functions to expose?
  • Overloads – Provide enough for pleasant user experience
  • Proxies Implementation
  • Translating String.StartsWith, String.EndsWith and String.Contains to LIKE in LINQ to Entities

New Features in Entity Designer Impacting Providers

  • Model First

Elisa Flasko posted a detailed UPDATED WIKI: Home item on 10/19/2009 to the ADO.NET Entity Framework & LINQ to Relational Data (a.k.a. AdoNetEfx) blog containing detailed links in the following categories:

  • Entity Framework Toolkits & Extensions
  • Entity Framework Samples
  • LINQ to SQL Samples
  • Entity Framework Learning Tools

Thanks, Elisa!


See the “LINQ to SQL Samples” category in Elisa Flasko’s post above.

Jim Wooley explains Setting DataContext Connection String in Data Tier in this 10/21/2009 post:

LINQ to SQL offers a quick mechanism to build a data tier in a n-Tier application. There’s a challenge when using the DBML designer in a Class Library. The designer stores the connection string in the Settings file. Although it appears that you can change it in the config file, any changes you make there will be ignored because they are actually retained in the generated Settings file.

While you could go into the DataContext’s .Designer file and change the location of the connection string, any changes you make there will be overwritten if you make changes to the DBML file. So what are you to do?

Jim continues with a detailed solution.

LINQ to Objects, LINQ to XML, et al.

Florent Clairambault’s LINQ : Join with multiple conditions of 10/21/2009 explains:

I wanted to some simple join in LINQ on multiple criteria. And coming from standard SQL it’s not as straightforward as I thought it would be. The little disturbing thing is that you lose auto-completion.

Eric continues with SQL and LINQ syntax examples.

Beth Massi’s SDC 2009 Recap & Surprise post of 10/20/2009 begins:

SDC09 has been a blast. I just finished my last session on Building Office Business Applications with Visual Studio 2010 and I think it went well. We created an OBA for good old Northwind Traders. I migrated the 2008 code which is here on code gallery into VS 2010 and showed the new features of VS2010 that makes Office development easier focusing on RAD data binding (including WPF) and designers, new multi-project deployment, and SharePoint 2010 tools. …

I also did a talk on using Open XML and LINQ to XML to manipulate Office 2007 document formats.

And ends with an admission that October 20 is Beth’s birthday. Happy Birthday, Beth!

Deborah Kurata explains Populating a DataGridView from Xml Data in this 10/20/209 post:

If you are using XML in a WinForms application you may find the need to display the XML data in a DataGridView.

Let's take this XML:

    <state name="California">
    <state name="Wisconsin">

Displaying XML in a DataGridView sounds easy, but if you just set the DataGridView DataSource to the XML data, you will get something like this:


Notice how it has lots of yuck in it: attribute details, node properties, and so on for every node in the XML. So how do you get something more like this:


The trick is to use anonymous types.

Deborah then shows you how to “use anonymous types.”

ADO.NET Data Services (Astoria)

Alex James explains Using Data Services over SharePoint 2010 – Part 1 – Getting Started in this detailed 10/21/2009 post:

ADO.NET Data Services 1.5 and SharePoint 2010 allow developers to write applications against SharePoint Lists using the familiar Data Services Client programming model.


The SharePoint 2010 beta will become generally available in November.

In order to use Data Services with SharePoint 2010 Beta, ADO.NET Data Services 1.5 must be installed on your server *before* you install SharePoint 2010.

And then to program against a Data Services enabled SharePoint box you need either:

  • VS 2008 SP1 with the ADO.NET Data Services 1.5 installed (CTP 2 or higher) or
  • VS 2010 (Beta 2 or higher)
Where is your Data Service Endpoint?

Assuming you’ve got everything setup and working the first thing you need to know is where your Data Service endpoint is installed.

If your SharePoint site is http://mflasko-dev/ (thanks Mike) then your Data Services endpoint will be http://mflasko-dev/_vti_bin/listdata.svc.

If you open one of these endpoints up in Internet Explorer you’ll see something like this:


As you can see this is a standard Data Services Atom feed, listing all the Lists on the SharePoint site.


Once you know where your Data Service is located, the next step is to write your Data Services Client application.

Alex continues with code for a sample Astoria client.

ASP.NET Dynamic Data (DD)

No significant new posts found this week.

blog comments powered by Disqus