Saturday, February 23, 2008

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

Alex James Posts a Teaser About Entity Framework Support for Associations with Payloads

As Alex mentions in his Associations with Payloads post of 7/24/2008, Entity Framework (EF)automatically creates a many:many association instead of an entity for a table that consists entirely of two (or more) foreign key fields.

If you add payload field(s) to the table, such as Quantity [,UnitPrice, Discount, etc.], EF treats the table as an entity with one:many and many:one associations with its related tables.

Alex says:

It turns out however that with a little jigger pokery in the CSDL, MSL and SSDL it does support them, sort of.

However he doesn't provide the "jigger pokery," which I assume is Kiwi for "hack" or the like, but says it's coming in the next post. Since his last preceding post was February 11, you might be in suspense for a couple of weeks.

Scott Hanselman Uses LINQ to XSD as an Example of How Microsoft Projects Appear to be Abandoned

"Is _______ dead? I haven't heard anything in a month from _____ team's blog! It must be dead.

and then goes on to describe the benefits of augmenting LINQ to XML with LINQ to XSD using the arcane Open Financial Exchange (Ofx) XML schemas. (Microsoft, CheckFree, and Intuit initiated Ofx, which appears to have a semi-active blog.).

I suggested in a comment:

Another way to indicate a project isn't dead is to respond to questions about its status in the appropriate MSDN forum.

I requested the status of LINQ to XSD for .NET 3.5 RTM in a LINQ Project General forum Status of LINQ to XSD for RTM? on November 17, 2007. Two others seconded my request.

Not a word from the XML team.

I'm trying again with a status request for Shyam Pather's LINQ to Stored XML implementation, but I'm not optimistic about the result.

See the "LINQ to XSD Alpha 0.2 for VS 2008 RTM Is Available for Downloading" topic below for more details and background on the new release.

Added: 2/23/2008

Jim Wooley Uses LINQ to XML to Query All Shakespeare Plays Very Quickly

Jim's Querying the complete plays of Shakespeare using LINQ to XML post of February 22, 2008 describes his quest to find with LINQ to XML the fifty characters (SPEAKERS) in 37 plays having the most LINEs. The total size of the 37 files he concatenated into a single collection of XElements is about 7.75 MB.

Jim says:

The amazing thing with this process, running all three queries here, including the one which loads the full XML from the various files takes less than a second. I haven't had time to do a full performance test, including memory load, but the initial results are quite impressive! [Emphasis added.]

I agree.

Added: 2/23/2008

LINQ to Objects and LINQ to XML Videos from Tech*Ed 2007 Developers Barcelona Start with Disclaimer

Charlie Calvert's Video of Luke Hoban's In-Depth Look at C# 3.0 post of February 22, 2008 points to videos of these two presentations:

These are the first videos of presentations from Microsoft events that start with a disclaimer. Fortunately, you don't need to choose the "I have read the disclaimer and agree to be bound by it" option to watch the segment. I'm waiting for the first conference that requires agreement to a disclaimer as a condition of registration.

Added: 2/23/2008

Scott Guthrie: Silverlight 2.0 Beta 1 Will Support LINQ to XML

Scott's First Look at Silverlight 2 post of February 22, 2008 says that his team is "shortly going to release the first public beta of Silverlight 2" and notes that:

It also includes LINQ and LINQ to XML library support (enabling easy transformation and querying of data), as well as local data caching and storage support. The .NET APIs in Silverlight are a compatible subset of the full .NET Framework.

It's amazing that the Silverlight team has been able to incorporate such an amazing array of new features in such a small package:

The Beta1 release of Silverlight 2 is 4.3MB in size, and takes 4-10 seconds to install on a machine that doesn't already have it.

LINQ to XSD Alpha 0.2 for VS 2008 RTM Is Available for Downloading

I’m happy to announce that today we are re-releasing the LINQ to XSD Preview Alpha 0.2 for Visual Studio 2008. The previous preview release of LINQ to XSD targeted Beta 1 of Visual Studio 2008 but did not work on later builds. Many of the people who originally downloaded and tried the LINQ to XSD Preview Alpha requested an update for the final release of Visual Studio 2008 – this release is it. You can download it from here.

I'm one of the one of "the people who originally downloaded and tried the LINQ to XSD Preview Alpha" who "requested an update for the final release of Visual Studio 2008." See my LINQ to XSD Redux and LINQ to Stored XML Coming post of December 4, 2007 (Updated 1/14/2008) for more background on the original development of LINQ to XSD by Ralf Lammel.

Good news! Now what we need from the XML Team is a progress report on LINQ to Stored XML.

Added: 2/21/2008

ADO.NET Team: LINQ to SQL Support for New SQL Server 2008 Features "Coming Soon"

According to Faisal Mohamood, LINQ to SQL Program Manager, in his Coming soon to LINQ to SQL post of February 21, 2008:

Things aren’t so quiet over here on our end, even if it looks that way. The team has been busy adding features so that you will have better support for SQL Server 2008 in the future. Things we’ve been working on include support for new T-SQL data types that are being introduced in SQL Server 2008 – namely DATE, TIME, DATETIME2 and DATETIMEOFFSET, so that you can enjoy the same rich LINQ support and CUD support over data that uses many of the new types that are being introduced in SQL Server 2008.

Stay tuned and watch this blog for more on this as we get closer to releasing some of this and other new functionality!

Sounds to me like the LINQ to SQL upgrade is a candidate for VS 2008 SP1.

Added: 2/21/2008

VS 2008 SP1 Appears to be in the Works Before the Product's Official Release

Ambrish's post includes step by step instructions for creating a working Entity Data Model with the included Northwind.sdf database file.

You can download SSCE v3.5 SP1 Beta for EF Beta 3 here. Be sure to check out the ReadMe file before installing this SSCE Beta, which obviously is not fully cooked. There are 11 known issues, some of which seem to me to be serious deficiencies.

I remain curious as to why anyone would layer heavyweight EF components over a lightweight, single-user database like SSCE.

Added: 2/21/2008

Roger Alsing: LINQ to NPersist Is Progressing

Roger's More Linq support for NPersist post of February 20, 2008 describes his technique for adding LINQ support for Mats Helander's NPersist object/relational mapping tool by generating LINQ-like NPath instead of SQL queries. Mats welcomed Roger back to the NPersist project in his Roger Is Back post of January 9, 2008. NPersist is now at version 1.0.10; you can read more about it in this 200-page Inside NPersist manual (.doc format).

Richard Bushell: Use Timestamp Fields for Concurrency Conflict Management with the LinqDataSource Control

If you use LINQ to SQL's default value-based concurrency conflict management feature, the LinqDataSource control stores the original values in ViewState. In his The LinqDataSource and the Hidden Viewstate of 2/21/2008, Richard goes into detail about how value-based concurrency works and the value of replacing original values with a single timestamp column.

Ruurd Boeke Continues His Postcompiling for Entity Framework Series

Ruurd's initial post about using PostSharp to add IPOCO interfaces to an Entity Data Model (see the "An Automatic IPOCO Implementation for Entity Framework" topic below) has turned into a Postcompiling for Entity Framework series. Here's his table of contents with current links:

Beth's One-To-Many (Master-Detail) Forms with LINQ to SQL post of 2/19/2008 shows you how to create an Orders/OrderDetails master-detail form, save edits made with stored procedures to the entities, and eliminate associated entity and referential integrity conflict exceptions when deleting OrderDetails entities.

Beth doesn't use Northwind for the demo because she wants foreign key values to be NOT NULL and use timestamp columns for concurrency conflict management. Both good ideas, but easy to implement on a copy of Northwind.

Added: 2/19/2008

Frans Bouma Tackles Function Mapping and Local Methods in LINQ to LLBLGen Pro

Frans is closing in on his epic LINQ to LLBLGen Pro implementation in Developing Linq to LLBLGen Pro, part 13 of February 19, 2008. This episode deals with issues with invoking functions within LINQ queries that don't map to database functions.

All store-specific ADO.NET data providers must support a designated set of canonical functions defined for aggregate, bitwise, date and time, math, string and other operations. Functions invoked by members of a projection that aren't canonical functions will execute on the result set in memory but not if they're included in the query (for example, in the Where clause.)

Frans' post deals with the following specific issues:

Constants in the projection

In-memory methods/property calls in the projection

Mapping methods and properties as database constructs

Booleans in projections

Lambda-based function usage

Object creation inside projections

LINQ to SQL oddness

and is longer than most of my posts!

His next post, which he hopes will be the last will cover defining function mappings for RDBMSs other than SQL Server and adapting LINQ queries to use LLBLGen's prefetch paths feature.

Added: 2/19/2008

Jim Wooley Explores LINQ Queries Against Self-Joined Tables

Jim's Managing self-referencing tables with LINQ to SQL post of February 18, 2008, demonstrates how to query a table with a self-join that generates a data tree. He uses the Northwind Employees table whose ReportsTo column contains the EmployeeID of the person's boss.

This write up briefly describes how we model associations between resources as Atom links and proposes a usage pattern of the atom:link element to support retrieving resource graphs in a single response. We're looking for feedback on the approach and also to get folks thinking about inlined content and whether it should be considered an extension to Atom.

with the "starting" end of the association as the title. An alternative is a custom Atom attribute. I recommend minimizing the use of custom attributes. It would be helpful if developers using Entity Framework data sources would singularize EntityType names and End names of the 1 or 0...1 side of AssociationSets, as in the above example. Processing should retain the nouns' number.

2. Expanding links inline. Using the current $include constructs to indicate which associations to expand and include them as content within the <link> element seems appropriate to me.

Note: This may expand into an independent post after I do some additional investigation on the topic, as well as how ADO.NET Data Services fit into the Internet Service Bus that's implemented as a CTP by BizTalk Services.

Update 2/22/2008: Pablo's "Data Friction", spot-on post of February 20, 2008 cites and agrees with Jon Udell's Overcoming data friction article of the same date, which laments the need for Web screen scraping because the underlying databases aren't Web-accessible.

interfaces, which increase the Entity Framework's "persistence ignorance quotient" to IPOCO (Plain Old CLR Objects with Interfaces). Postsharp automatically generates and implements the three interfaces from a POCO class in IL when you build your project. However, the class must be decorated with a custom attribute.

The Postsharp folks ask:

Have you already implemented things like transaction management, logging, caching, or security? In each method, you had to write a same dozen of lines of code, right?

With PostSharp, you can encapsulate these aspects as custom attributes. You can make your own custom attributes that will really add new behaviors to your code! This is sometimes called aspect-oriented programming (AOP) or policy injection.

LINQ to Opf3: An Implementation of LINQ for Chili Software's Opf3 O/RM

Christian Liensberger's Opf3 and LINQ support post of February 18, 2008 announces that Chili Software's Object Persistence Framework 3 (Opf3) now includes support for LINQ by adding the Chili.Opf3.Linq namespace.

Opf3 is a simple O/RM that offers a free Express Edition that maps up to eight tables to classes with a maximum of eight properties each. Opf3 supports most popular commercial and open-source databases that have ODBC or OLE DB drivers.

A single developer license with source code costs US$199; a site license is $699. A wizard plug-in that generates classes and enables customizing the autogenerated mapping is available for $99 and $349. Opf3/Wizard bundles are $249 (single) and $999 (site).

For comparison, LLBLGen Pro licenses range from €229 for a single license to €159 each for 20 or more, excluding VAT.

Charlie Calvert: LINQ Librarian

Charlie's LINQ Books post of February 17, 2008 lists published and forthcoming LINQ-related books in the following categories:

The dual Web role application has been running in Microsoft's South Central US (San Antonio) data center since September 2009. I believe it is the oldest continuously running Windows Azure application.

About Me

I'm a Windows Azure Insider, a retired Windows Azure MVP, the principal developer for OakLeaf Systems and the author of 30+ books on Microsoft software. The books have more than 1.25 million English copies in print and have been translated into 20+ languages.

Full disclosure: I make part of my livelihood by writing about Microsoft products in books and for magazines. I regularly receive free evaluation software from Microsoft and press credentials for Microsoft Tech•Ed and PDC. I'm also a member of the Microsoft Partner Network.