Sunday, March 29, 2009

LINQ and Entity Framework Posts for 3/23/2009+

• Updates: 3/28/2009 and 3/29/2009

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

Entity Framework and Entity Data Model (EF/EDM)

Julie Lerman takes on many-to-many associations again in her Inserting Many to Many Relationships in EF with or without a Join Entity post of 3/29/2009.

Binary Bob’s Disconnected Clients, Changed data and Entity Framework post of 3/25/2009 discusses the use of EF with Silverlight apps. Bob writes:

Entity Framework is here to stay as Microsoft is steering future development towards its use. But if you use Entity Framework in your Silverlight apps, you may bump up against some hurdles trying to persist changes made to the Entities on the client back to the store.

and decides to use .NET RIA Services to make the connection. Bob’s More than one way to skin an EDM query post of 3/22/2009 provides a diagram that helps you “to conceptualize the whole framework and understand the pieces of the stack, what they offer and how they interrelate.”

Lynn Eriksen asks Ado.Net Data Services – Are you experienced? on 3/24/2009 and proceeds to share his experiences when deploying his first EF application.

Alex JamesIndex of Tips of 3/25/2009 has links to the first nine of his useful tips for working with Entity Framework v1 and LINQ to Entities.

Jeff Derstadt explains in Self-Tracking Entities in the Entity Framework post of 3/23/2009 how self-tracking entities will work in EF v2. Jeff describes them:

Self-tracking entities know how to do their own change tracking regardless of which tier those changes are made on. As an architecture, self-tracking entities falls between DTOs and DataSets and includes some of the benefits of each.

Simon Segal reports on his Entity Framework Profiler – Progress as of 3/22/2009. His earlier A Profiler for the Entity Framework – Proposed post of 3/21/2009 explains:

The .ToTraceString() method and the SQL Server Profiler are just too disconnected to provide me with a solution to analysing and logging the SQL Query output produced by my Entity Framework code. To change that, I am currently working on a profiler for the Entity Framework. Of course the inspiration to start on this project came from watching what Ayende was doing with NHProf (which is incredible), however I should point out that this project does not seek in any way nor set out to accomplish the same goals, it is my attempt at building myself a usable tool for a job and if it can anyone else then that’s great too.

Joel Reyes tackles READERS COMMENTS: performance of EF vs. LINQ to SQL in this generalized post of 3/20/2009 that begins:

Original Comment: “EF ObjectQueries seem to create some pretty poorly performing queries compared to LINQ in my experience. 2. If you are saying Entity SQL performs really well, what are you comparing this to, ObjectQueries or other data access technologies?”

and ends:

All that said, we have been continuously investing in improving the SQL generated by EF, by improving the query trees we generate and by improving the provider we own: the one that generates T-SQL for SQL Server. We have also invested substantially in fixing LINQ to SQL bugs and in improving things like how both technologies handle string parameters. Hopefully, the fruits of these investment will be apparent in the versions that we will release with .NET 4.0 and Visual Studio 2010.

In fact on April 08th we will have  a  webcast exploring the new additions and improvements made to EF in .NET 4.0. Stay tuned!

Alex James’ Foreign Keys in the Entity Framework post of 3/16/2009 notes the controversy surrounding exposing FK values in the Entity Data Model v2 but decides:

Those who want FKs in their Entities should be able to do so, so they can gain all the benefits that having FKs in your Entities undoubtedly provide. On the other hand customers who are concerned that have FKs in their Entities in someway pollutes their model can continue to use the type of associations we had in .NET 3.5 SP1.

Hoorah! I’ve been clamoring for optional surfacing of FK values since the initial EF v1 preview.


Chris Rock’s Implicit conversion from data type sql_variant to uniqueidentifer is not allowed. post of 3/23/2009 describes how to recover from the dreaded "Implicit conversion from data type sql_variant to uniqueidentifer is not allowed. User the CONVERT function to run this query" exception.

Sergey Zwezdin explains the importance of applying the DataServiceKey attribute when writing the constructor for an entity’s primary key(s) in his ADO.NET Data Services and LINQ-to-SQL and ADO.NET Data Services и LINQ to SQL: continuation posts of 3/23/2009 and 3/24/2009.

Damien Guard starts a LINQ to SQL tips and tricks series with LINQ to SQL tips and tricks #1 of 3/16/2009: Loading a delay-loaded property. Damien writes:

LINQ to SQL lets you specify that a property is delay-loaded meaning that it is not normally retrieved as part of normal query operations against that entity. This is particularly useful for binary and large text fields such as a photo property on an employee object that is rarely used and would cause a large amount of memory to be consumed on the client not to mention traffic between the SQL and application.

Other topics include “Multiple entity types from a single stored procedure” and “Intercepting create, update and delete operations.”

Thanks to Damien for the heads up on Twitter.

LINQ to Objects, LINQ to XML, et al.

• Bart de Smet’s ExceLINQ – Not Your Typical LINQ Provider post of 3/28/2009 describes his LINQ to Excel provider that generates an Excel chart from worksheet values. Here’s Bart’s pseudocode:


You can download the prototype here.

• Arjan Einbu describes an extension method for the TextReader class in his Parsing textfiles with LINQ (or LINQ-to-TextReader) post of 3/27/2009.

• Jacob Proffitt describes his work on a LINQ provider for in his Multiple Blog Data post of 3/27/2009. Jacob created a new beta release at the project’s homepage (CodePlex) for users.

Michaël HompusGenerate integer lists using LINQ post of 3/25/2009 shows you how to return an IEnumerable<int> collection with the corresponding range of values with LINQ’s Range() method.

Alexandra Rusina, a Microsoft programming writer, explains How to use LINQ methods to compare objects of custom types in this 3/25/2009 post to the C# Frequently Asked Questions blog.

Charlie Calvert’s Essential LINQ Published post of 3/21/2009 describes his pleasure in receiving “a box full of the first copies of his most recent book.”

I know the feeling.

Eric White’s Announcing the Release of PowerTools for Open XML V1.1 post of 3/19/2009:

PowerTools for Open XML is an open source project on CodePlex that makes it easy to create and modify Open XML documents using PowerShell scripts. I introduced the PowerTools for Open XML in June 2008 in the post, Automated Processing of Open XML Documents using PowerShell.

ADO.NET Data Services (Astoria)

• Rob Fonseca-Ensor’s Use T4 code generation to add INotifyPropertyChanged to ADO.Net Data Services (Astoria) Entities post of 3/26/2009 begins:

The current version of ADO.Net Data Services (Astoria) for Silverlight generates some extremely Plain Old CLR Objects. As Shawn Wildermuth notes, you dont even get INotifyPropertyChanged support. You might need this if you want to databind directly to your Astoria entities, but if you’re doing serious Silverlight work, it pays to wrap your entities up in a ViewModel. Even if you’re doing this, having INotifyPropertyChanged support can really help - for example, instead of saving every single entity on your model, you only need to fire the ones that change.

Rob provides a sample T4 template that solves the problem.

• Phani Raju continues his series on the ADO.NET Data Services upgrade with ADO.NET Data Services Friendly Feeds , Mapping EDM Types – I of 3/28/2009, which provides “some samples of how to map your entity properties to Atom/custom markup in the atom:entry element.”

Phani’s ADO.NET Data Services Friendly Feeds , Mapping CLR Types of 3/20/2009 includes “some samples of how to map your entity properties to Atom/custom markup in the atom:entry element.”

Sergey Zwezdin’s Debugging ADO.NET Data Services post of 3/29/2009 explains how to use the InitializeService method to write logs for Request Error messages that tell you to “See server logs for more details.”

ASP.NET Dynamic Data (DD)

Steve Naughton’s Cascading Filters – Dynamic Data Futures (Futures on Codeplex) post of 3/27/2009 is the second in the DD Cascading Filters series that began with:

Steve Naughton’s Cascading Filters – for Dynamic Data v1.0 appeared 3/26/2009. Steve writes:

This is an article is a follow on from my previous article Cascading or Dependant Field Templates for ASP.Net 4.0 Preview and is the start of a series of three articles which describe Cascading Filters for:

  1. Dynamic Data (v1.0) .Net 3.5 SP1
  2. Dynamic Data Futures (Futures on Codeplex)
  3. Dynamic Data Preview 3 (Preview 3 on Codeplex)

This first version is pretty similar to the previous article on cascading FieldTemplates here we will adapt the CascadingFieldTemplate class to facilitate our need for cascading filters.

Dave Ebbo explains Using a DomainService in ASP.NET and Dynamic Data in this 3/24/2009 post. Dave writes:

One of the big things that I discussed in my MIX talk is the new DomainDataSource control.  It is currently available in Preview form as part of ASP.NET Dynamic Data 4.0 Preview 3.  This can be confusing, because even though Dynamic Data makes use of DomainDataSource, DomainDataSource is absolutely not tied to Dynamic Data, and is fully usable in ‘regular’ aspx pages.

SQL Data Services (SDS) and Cloud Computing

This topic moved on 1/3/2009 to Windows Azure and Cloud Computing Posts for 1/5/2009+.

Miscellaneous (WPF, WCF, MVC, Silverlight, etc.)

Rob Conery announces that the MVC Storefront’s project name has changed to “Kona” in his Kona Screencast 1: It’s Baaaaack! post of 3/27/2009. Rob writes:

This may be a really dumb thing I’ve just done – but bear with me because I think it makes sense. I knew this point was going to come when I first started the MVC Storefront – the point where I’m no longer building “an MVC sample app” and I change directions to build a flexible, pluggable Open Source community application. So I decided to mark the occasion by changing the application name from MVC Storefront to Kona. This screencast is all about that change and what’s become of the MVC Storefront.

His post includes a link to a 40 MB Kona 1 Webcast.

Dinesh Kulkarni’s .NET RIA Services Resources (for March 2009 Preview) post of 3/26/2009 also includes a “Common questions and quick answers” section about .NET RIA Services.