Saturday, August 08, 2009

LINQ and Entity Framework Posts for 8/3/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)

Alex James delivers Tip 30 – How to use a custom database function on 8/6/2009.

Syed Mehroz Alam finds Entity Framework: TimeStamp fields not recognized for optimistic concurrency model on 8/5/2009:

Today, while working with Entity Framework, I noticed through SQL Profiler that my update queries were not using timestamp field. I looked into my model and found that my timestamp fields have Concurrency Mode property set to None. It was quite strange; The entity model was auto generated and I wonder why the EF designer could not identify my timestamp field (I remember LINQ To SQL designer automatically took care of such fields). Anyway, I changed Concurrency Mode to Fixed and it worked great. So, as a final note, when generating entity model from database, don’t forget to set appropriate concurrency modes for your timestamp fields as it is not done by the designer itself.

Kati Iceva reports Improvements to the Generated SQL in .NET 4.0 Beta1 in this 8/3/2009 post:

Most of the improvements we have made are in the Entity Framework query pipeline as opposed to specific SqlClient changes. Because the changes were in the query pipeline, this results in simpler output command trees and thus would affect the SQL generated by any backend, not only by our SQL Server provider.

Following are the improvements:

    • Avoid projecting all columns in nested queries
    • Avoiding Unnecessary IS NULL Checks in LINQ to Entities Queries
    • Additional join elimination:  Eliminate parent table in “Child Left Outer Join Parent”
    • Using IN instead of nested OR’s
    • Translating more of LINQ’s GroupBy operator into GROUP BY
    • Avoiding “Cast (1 as bit)”, using “1” instead
    • Simplifying some queries that go against a subtype in a type hierarchy
    • Improvements in .NET 4.0 post Beta1 (a list)

The team’s post provides detailed code examples for the preceding mprovements.

Julie Lerman provides an abbreviated version of the preceding improvements in her Important Entity Framework Query Improvements for .NET 4.0 post of 8/8/2009 and identities its author as Kati Iceva.

Beth Massi reviews EF-related articles by Danny Simmons and Tim Mallalieu in MSDN Magazine’s August 2009 issue in her N-Tier Application Patterns with Entity Framework post of 8/5/2009:

This month’s MSDN Magazine has a particularly good article in there by Danny Simmons, Development Manager on the Entity Framework team, on N-Tier Application Patterns with Entity Framework that I recommend reading through. He explains the design considerations you need to take into account when building n-tier applications and also discusses some of the improvements that are coming in .NET Framework 4.0 that will make building n-tier applications with EF much much easier. I’m personally looking forward to self-tracking entities myself, hooray!

Tim Mallalieu also has a good best practices article in this issue that I just started digging into regarding the next version of Entity Framework.

Alex James reports in his Code Only Enhancements post of 8/3/2009 that:

The Entity Framework Design team has been working hard on Code Only since the first preview of CodeOnly.

In the next release you will be able to specify:

  1. Navigation Property Inverses.
  2. Property Facets, like Nullability, MaxLength, Precision etc.
  3. Property to Column mappings
  4. Type to Table(s) mappings
  5. Inheritance strategy
  6. Encapsulate configuration

The rest of this post will drill into each of these features in turn.

Alex provides code samples for the following operations:

  • Registering NavigationProperty inverses
  • Specifying Property Facets
  • Specifying Mappings
  • Specifying Inheritance
  • Default Foreign Key Locations
  • Specifying Join Table Mappings
  • Entity Splitting
  • Encapsulating all the Configuration

Julie Lerman gives her analysis of the Next version of EF Code Only Design laid out by MS on 8/7/2009 and offers a Short Video about [her] book on Amazon.com on 8/6/2009.

Nuno Filipe Godinho summarizes recent Improvements in Entity Framework 4.0 in this 8/6/2009 post.

Bob Beauchemin says in his Upcoming improvements in EDM T-SQL code generation post of 8/7/2009:

I'd really like to see support in the EDM provider for SQL Server (and LINQ to SQL) for the spatial and hierarchyid data types (and UDTs in general), table-valued parameters, filestream through the streaming APIs, and better support for stored procedures (beyong the ComplexType generation that's in EDM 4.0 beta) and UDFs. This would complete and enhance the SQL Server support in future.

Me too, Bob.

Matthieu Mezil’s How to get the typed instance in the abstract class? post of 8/3/2009 takes a C# 2.0 approach to Alex James’ Another C# trick: Fluents, Inheritance and Extension Methods post of 8/1/2009 and Damien Guards related extension methods.

LINQ to SQL

Tony Sneed asks and answers Who is Improving LINQ to SQL? Plinqo by Code Smith! on 8/4/2009:

A lot of people have lingering doubts about whether to use LINQ to SQL for real-world applications, especially since Microsoft has left it to languish in favor of the new version of the Entity Framework slated for release with .NET 4.0 and Visual Studio 2010. Nevertheless, I have a consulting client, Credit Solutions, that uses LINQ to SQL for their line-of-business web application and has had a very favorable experience working with it. In addition you’ll get better performance using LINQ to SQL (we’ll see how EF4 compares when it comes out).

The bottom line is that LINQ to SQL is a perfectly viable alternative when you can guarantee that the database will be Microsoft SQL Server (2000 or later). It has support for POCO (persistence ignorance), stored procedures, lazy loading, and concurrency management, and it works well with SOA (n-tier) architectures.

The question is, "Who is adding new features to LINQ to SQL?" The answer is a product called Plinqo, created by the makers of the code-generation tool, Code Smith. The purpose of Plinqo is to generate LINQ to SQL entities that replace those created when you add a dbml file to a Visual Studio project. In fact, Plinqo will generate the dbml file for you, placing each entity in a separate .cs file under a common folder. Actually, Plinqo creates two files: one for the code-generated entity, and another for your own custom metadata that will not be overwritten by the code-generator (for example, attributes that can drive a dynamic data web site). …

So before you decide to give up on LINQ to SQL, check out Plinqo to get a fresh option for using LINQ to SQL in real-world applications. They’re even offering a free CodeSmith license if you mention Plinqo in a blog or tweet.

I’m glad to see more ISVs (in addition to Huagati Systems) supporting LINQ to SQL.

LINQ to Objects, LINQ to XML, et al.

Tormod Fjeldskår suggests Thinking in Sequences in this 8/7/2009 post:

When dealing with series of objects, it is easy to think of them as lists, or arrays. That is, after all, the first collection types most people get acquainted with when becoming a programmer. And by all means, lists are very versatile and easy to employ in most situations. However, they often provide more functionality than you strictly need. Rather than considering collections of objects as list, I find it helpful to think of them as sequences.

LinqMaster explains How to Use LINQ TakeWhile in this 8/5/2009 post.

Damien Guard describes an extension method in his Dictionary<T> look-up or create made simpler post of 8/4/2009 that simplifies such a static class.

ADO.NET Data Services (Astoria)

Nuno Filipe Godinho’s ADO.NET Data Services post of 8/6/2009 lists the operations that Astoria supports and a link for the ADO.NET Data Services Datasheet (CheatSheet) provided by Robert Maclean.

ASP.NET Dynamic Data (DD)

No significant LINQ or EF-related articles as of 8/8/2009 11:00 AM PDT.

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

No significant LINQ or EF-related articles as of 8/8/2009 11:00 AM PDT. 

blog comments powered by Disqus