Monday, October 15, 2007

LINQ and Entity Framework Posts for 10/15+

Mike Taulty Customizes a Wrapper for System.Data.Entity.Design Classes

Mike's LINQ to Entities - Customising the edmgen.exe Output post of 10/21/2007 shows you how to write a configuration file that customizes the EdmGen.exe process with added attributes. Mike says you can "add extra interfaces and members to the entity classes," but his sample doesn't demonstrate this.

Added 10/22/2007

Julie Lerman on Improving Entity Framework Performance with DataReaders

Julie's EF EntityClient for performance post of 10/19/2007 qualifies her earlier Choosing LINQ to Entities vs Entity SQL vs. EntityClient post by noting that "one of the most important reasons about being able to return datareaders, in case it isn't obvious: Performance. But note that this is for reading only."

Added 10/22/2007

Scott Guthrie's Current LINQ to SQL Posts in PDF Format

Kadir Pakel has assembled a compilation of ScottGu's first nine LINQ to SQL blog posts into a 118-page, fully formatted PDF document.

In an October 9, 2007 reply to a reader's comment, Scott says:

I'm hoping to do the next segment this upcoming weekend.  They tend to take several hours to write, and I've been really busy the last few weeks, which is why the delay.  Hopefully I'll find a few hours to produce more soon!

As I recall, one of the topics on tap relates to multi-tier deployment of LINQ to SQL with WCF. I hope Scott reads Dinesh's and my posts on the topic before writing much code.

Added 10/19/2007

It's True: LINQ to SQL Has No "Out-of-the-Box Multi-Tier Story!"

This is my detailed description of an attempt to work around item #2 of Dinesh Kulkarni's LINQ to SQL: What is NOT in RTM (V1) post. The project adds two levels of EntityRefs to a databound test harness that implements Mike Taulty's not-so-mini, unbound ClientSideContext in a WCF client.

The article was last updated 10/19/2007 at 1300 PST.

Added 10/19/2007

Julie Lehrman: Choosing LINQ to Entities vs Entity SQL vs. EntityClient

Julie says the title should have been "Choosing LINQ to Entities vs. Entity SQL+Object Services vs. Entity SQL+EntityClient" as she describes which approach is the most practical for specific data access projects.

LINQ Cookbook, Recipe 9: Dynamic Sort Order from the VB Team

The VB Team claims:

This recipe shows how to create a custom function to provide values to be used when sorting a LINQ query.

Added 10/19/2007

Beth Massi on Getting Started with LINQ to XML

Beth suggests watching an overview to LINQ to XML video and then digging into what she "would have shown next." 

Dinesh Kulkarni: LINQ to SQL: What is NOT in RTM (V1)

Dinesh Kulkarni admits in his October 15, 2007 LINQ to SQL: What is NOT in RTM (V1) post that LINQ to SQL v1 will be missing (at least) the following features:

  1. Support for other databases with or without a public provider model.
  2. Out-of-the-box multi-tier story.
  3. Handling schema changes.
  4. Support for specific mappings (value types and m:n relationships with no relation table.)
  5. Identity between designer, SqlMetal and run-time (external mapping file and SSC support in designer)
  6. LINQ to SQL in compact framework.

[I've abbreviated Dinesh's topics and the emphasis is mine.]

See my LINQ to SQL Has No "Out-of-the-Box Multi-Tier Story!" for more details.

Added 10/19/2007

LINQ to SQL's GetOriginalEntityState() Method Has a Serious Bug

My GetOriginalEntityState() Loses EntitySet/EntityRef Data post of October 15, 2007 describes a problem with missing EntitySet and EntityRef property values when invoking the Table<TEntity>.GetOriginalEntityState(modifiedMember) method to retrieve the original values of an entity member. The Connect bug report is Feedback 304732: GetOriginalEntityState Doesn't Include EntitySet or Entity Ref Data for Related Entities of 10/15/2007. Matt Warren says it isn't a bug but at least he doesn't claim it's a feature.

Paul Stovell Introduces SyncLINQ for Databinding LINQ Queries

Austrailian .NET Developer and MVP Paul Stovell will release this week an early alpha version of his SyncLINQ extensions, which return collections that implement the System.ComponentModel namespace's INotifyCollectionChanged interface. This interface is an analog of the INotifyPropertyChanged interface that LINQ to SQL's DataContext class implements.

A quick description of SyncLINQ is a simple implementation of QueryNotifications for LINQ collections.

The first alpha will support:

  • Where()
  • Select(), including projections into anonymous types
  • OrderBy(), ThenBy() both ascending and descending
  • Union()

While waiting for the first bits to drop, you can watch Paul's seven-minute video clip that demonstrates SyncLINQ features from his Introducing SyncLINQ post of October 16, 2007 (Australian time).

Paul promises that SyncLINQ ultimately will:

  • Work against any LINQ provider
  • Support all LINQ extension methods
  • Provide two custom extension methods
    • Asynchronous() to run LINQ queries on a worker thread
    • ToSyncLinqPolling(time) to poll data sources
  • Work with Windows forms and WPF

Julie Lerman Checks Out Unit Testing for LINQ to SQL and Entity Framework

Julie's Unit testing LINQ to SQL and Entity Framework post of October 14, 2007 describes her exploratory work with the unit testing feature that the Visual Studio team finally added to the VS 2008 Professional Edition (in addition to its previous presence in the Team Client Edition).

K. Scott Allen's Unit Testing with Visual Studio 2008 post has a brief history of unit testing in Visual Studio, its early problems, and its current status (plus links to a couple of good unit-testing resources.)

Dinesh Kulkarni Objects to CRUD Methods in Entity Classes

His October 14, 2007 No CRUD on entity please (aka anti-pattern of DB access methods on data/biz object) post explains why CRUD (Create, Read, Updated, Delete) methods don't belong in entity classes without using the term persistence ignorance.

LINQ to SQL's DataContext object is responsible for all CRUD operations and supports Martin Fowler's Unit of Work pattern with an implicit transaction and concurrency conflict management.

Assigning all CRUD operations to the DataContext object is what makes Mike Taulty's ClientSideContext object usable as a "mini connectionless DataContext" when the GetOriginalEntityState() method's bigtime bug gets fixed.

Omar Al Zabir Emulates a Google Start Page with Linq to SQL, Linq to XML, et al.

Omar has created an Ajax Start Page, which he says is just like iGoogle, using LINQ to SQL, LINQ to XML, Workflow Foundation and ASP.NET AJAX 3.5. This Code Project document describes it and offers a link to downloadable source code.

You can read a full description and instructions for checking out the code in his Ajax Start Page using VS 2008 and .NET 3.5 post of October 14, 2007.

GetOriginalEntityState() Loses EntitySet/EntityRef Data

Mike Taulty's LINQ to SQL and WCF - Sharing types, subverting the DataContext on the client side post of October 8, 2007 suggests adding an "unbound" or "connectionless" DataContext object to a Windows Communication Foundation (WCF) client for tracking LINQ to SQL data changes.

As mentioned in the "Mike Taulty Implements an Unbound DataContext in a WCF Client" topic of LINQ and Entity Framework Posts for 10/5/2007+, a DataContext object that's not bound to a database is similar in concept to Matt Warren's promised serializable "mini connectionless DataContext" that I discussed in my Changes Coming to LINQ to SQL post of May 15, 2007. This feature won't be present in LINQ to SQL v1, but a useful alternative would be the source code for such an object to include in detached projects as a class library. Mike's approach appears to be useful as a workaround until the mini connectionless DataContext becomes available, but it requires an operable Table<TEntity>.GetOriginalEntityState(modifiedMember) method. 

Matt Warren says the method won't be changed! See Update at end of post.

The primary advantage of the client-side DataContext approach for a service-oriented LINQ to SQL implementation is a dramatic decrease in the number of WCF messages transmitted after editing multiple objects in a session. The client sends a List<T> of objects to be added, modified, or removed instead of a message for each individual object, which nicely implements Martin Fowler's Unit of Work pattern. The disadvantage is that the client uses only a small part of the heavyweight DataContext's resources, which primarily translate LINQ queries to SQL statements.

You can't serialize the DataContext itself but you can serialize the original entity state and its changes into List<TEntity> objects, store them in an ASP.NET Web page's ViewState and restore them after postbacks, as described by Julie Lerman for the Entity Framework in her Entity Framework object graphs and viewstate post of October 5, 2007.

Evidence of the GetModifiedMembers() Problem and Related Bugs

While testing a slightly more complex implementation of Mike's Client.exe program that eager-loads the Customer.Orders and Order.Order_Details (EntitySet) properties, I discovered that the Table<TEntity>.GetOriginalEntityState(modifiedMember) method applied to the DataContext.Customers returned Customer objects with Customer.Orders.Count = 0. The Table<TEntity>.GetModifiedMembers(ch => ch.ModifiedEntities) method has correct Customer.Orders.Count values so the change tracker interprets the Order objects as added and generates the T-SQL statements to add new Orders, as shown in the screen capture below.

A search on GetOriginalEntityState from Connect for Visual Studio's Search for a Duplicate Issue page returns no hits.

The problem has symptoms similar to those I reported in my Eager Loading Appears to Cause LINQ to SQL Entity Table Problems post of August 22, 2007 and Clarification of the Object Tracking Problem with LINQ to SQL's Eager Loading Feature item of August 24, 2007. However, the following fix proposed on 9/20/2007 by Alex Turner in my bug report 294781, LINQ to SQL Objects Eager Loaded with LoadOptions Aren't Recognized by Object Tracker (of 8/23/2007, status changed to fixed on 9/4/2007) doesn't reflect the failure of Table<TEntity>.GetOriginalEntityState(modifiedMember) to include EntitySet or EntityRef members:

Thanks for reporting this issue you've encountered with Visual Studio 2008! We looked into the issue and it was exactly as you described in your blog: when re-executing an eager-loaded query, we would send the top-level query again (the 1), but then after getting back the list of n objects that matched, send out n more queries to fetch their details, even if we already had them in the cache! In fact, when our Beta 2 logic went to materialize the returned objects from the redundant n queries, it would check then, see it already had the objects, and throw the data away. We've promoted that check to occur before dispatching the eager-loaded child queries and now when the query is re-executed, only the single top-level query is sent (in the table on your blog, the Eager Subsequent row would now look like the Deferred Subsequent row, all 1's).

Thanks again for the report!

Alex Turner
Program Manager
Visual C#

Checking for existence of objects in the local cache before issuing T-SQL SELECT batches won't solve this problem.

The problem might be a side-effect of or responsible for the issue described in bug report 295402: Incorrect Update Behavior - Attaching an Entity after Calling a Relationship Property of 8/27/2007. This report was closed as [to be] Fixed on 9/5/2007. For more details on that bug report and a sample of its affect on LINQ to SQL applications, see the "Fighting the Attached Associated Objects Bug" of LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1 of 10/9/2007.

The ClientSideContext Class and Initial WCF Test Harness

The unbound DataContext instance (ClientSideContext) provides Attach(), AttachAll(), Add(), AddAll(), Remove()and RemoveAll() methods for Table<TEntity> implementations of the ITable interface and stores the original and changed entity values. You apply changes to the attached entities directly. The Table<TEntity>.GetModifiedMembers() method contains references to added, removed, and modified members.

Invoking Mike's GetInserted(), GetModified() and GetDeleted() methods supply modified argument values to InsertEntity(modified, original) and UpdateEntity(original, modified) service methods. The Table<TEntity>.GetOriginalEntityState() method provides original argument values to the preceding two service methods, plus the DeleteEntity(original, modified) method. (DeleteEntity() requires both arguments because you must attach the entity before you remove it.)

Mike's sample code deals with the DataContext.Customers entity only and sets DataContext.DeferredLoadingEnabled = False on the client and DataContext.ObjectTrackingEnabled = False on the server when retrieving objects from the persistence store. Mike's test environment doesn't populate the Customer.Orders and Order.Order_Details (EntitySet) properties, and unidirectional binding prevents serializing the Order.Customer and Order_Details.Order (EntityRef) property values. The problem doesn't manifest until you eager-load the associated EntitySets.

Here's a screen capture of the first test harness showing a typical spurious INSERT operation for Order objects:

Even with only the seven UK orders processed by Mike's original client code, it doesn't take very many executions to add enough orders to exceed the client's default maxReceivedMessageSize value and throw Bad Request (HTTP: 400) exceptions.

Second Test Harness

To verify that the problem wasn't related to WCF or HTTP transport issues, I modified the code of an earlier test harness for conventional client/server LINQ to SQL operation. Here's the result of making a small change (Market -> Mart) to the GREAL Customer and (6 -> 7) to its last Order object and clicking Submit, which has test code added to it's Click event handler:

Click image for full size screen capture.

This test harness, which uses a standard Northwind database instance, is included with the new bug report.

The number of late (post beta 2) blocking bugs related to associations indicates to me that LINQ to SQL's automated test regimen doesn't include or or lacks depth in tests with objects from one or more related entities.

The Connect bug report is Feedback 304732: GetOriginalEntityState Doesn't Include EntitySet or Entity Ref Data for Related Entities of 10/15/2007.

Workaround

The obvious workaround is to use a timestamp or last-modified datetime column for consistency control. If you can't modify the underlying database tables, the alternative is to write code that maintains initial entity state information in a local List<TEntity>, as Julie Lerman proposed for the Entity Framework in her XML Serializing Entity Framework entities with their children for SOA post of October 2, 2007.

Update October 16, 2007: No Fix in Store for This Problem

Matt Warren added the following comment to the "LINQ to SQL's GetOriginalEntityState() Method Has Serious Bug" topic of my LINQ and Entity Framework Posts for 10/15+ post:

Roger, its not possible for GetOriginalEntityState to return copies of entities with EntityRef's and EntitySet's set. These associations are normally bi-directional, so only one entity instance can ever refer to another without duplicating the entire graph. The purpose of GetOriginalEntityState is to give back a copy of the entity with only the data fields set.

The "ITable.GetOriginalEntityState Method" help topic states that the method "Retrieves original values." The help topic states further in its remarks section:

Note the following:

  • The entity argument must be non-null. Otherwise, a null argument exception is thrown.

  • In the case of the strongly typed (TEntity) method: the type must be mapped and must be an entity type. That is, it must have object id information in its mapping. Otherwise, a wrong type exception is thrown.

There is nothing in the method's name or its help topic that would lead one to believe that its purpose "is to give back a copy of the entity with only the data fields set." Further, the corresponding modified members include EntitySet copies as property values. I no reason to treat original and modified members' EntitySets differently. (Serialized associations are unidirectional.)

The workaround doesn't appear to be pretty. Hopefully, fixing the two related bugs discussed earlier will mitigate the excessive number of T-SQL queries executed by the service.

Tuesday, October 09, 2007

LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1

Setting LINQ to SQL's Serialization property value for entities to Unidirectional in the O/R Designer's properties window for the entity enables Windows Communication Foundation's default DataContractSerializer (DCS). The DCS implements the Shared Contract mode, which (in Aaron Skonnard's words) "shares the schema contract across the wire." An alternative NetDataContractSerializer (NDCS) shares .NET Framework types and implements Shared Type mode, which isn't interoperable. The third alternative is .NET 2.0 and earlier's XMLSerializer.

However DCS doesn't maintain full object-graph schema fidelity of the original entity's properties. You lose EntityRefs for m:1 associations if your object has EntitySets for 1:n associations that share a common property. In this case, you have a circular reference or cycle. The DCS doesn't serialize circular references by default, so these EntityRef properties lose their [DataMember] attribute on the server and the [System.Runtime.Serialization.DataMemberAttribute()] decoration on the client. 

The DCS also adds an ExtensionData property of the ExtensionData type to support round-tripping with new service versions that have added properties. The property stores any data from future versions of the data contract that is unknown to the current version.

LINQ to SQL automatically adds the EntityRef value and you usually can ignore ExtensionData property. This article offers a link to a complex workaround to enable serializing EntityRefs for m:1 associations. This doesn't fully conform ServiceName.EntityName objects sent to and returned from service clients with the original DataContextName.EntityName objects because you can't remove the ExtensionData property.

The Entity Framework (EF) and Entity Data Model (EDM) support only binary serialization of entities and make no provision whatsoever for XML serialization of entity relationships. Julie Lerman addresses this issue in her XML Serializing Entity Framework entities with their children for SOA post of October 2, 2007. Julie proposes constructing a facade from the original entities and decorating the entity and member with [DataContract] and [DataMember] attributes to enable WCF serialization. It remains to be seen if WCF can handle cycles in facades; this is a more serious issue for the EF, because EntityRefs replace—rather than supplement—foreign-key values.

You must construct a similar facade to retain original entity values for updates to LINQ to SQL entities that require value-based concurrency management. Mike Taulty mentions this problem in his Disconnected LINQ to SQL post:

I had to write a function to copy a customer record so that I can maintain a "current" value and an "original" value (I didn't include this code as it's tedious - sometimes I find myself wishing that ICloneable was a bit more central in the .NET world.)

Adding a timestamp property to each entity eliminates the need to construct facades to hold original entity values. A timestamp property also lets you attach an entity to a DataContext with the Table<TEntity>.Attach(true) overload that specifies the entity as modified.

WCF's default configuration uses the WsHttpBinding binding to implement WS-Reliable Messaging and WS-Security specifications for message reliability, security and authentication. HTTP is the transport, messages are encoded as Text/XML and secured by SOAP message security; the SOAP body is encrypted and digitally signed by default. Message security and authentication are relatively fragile in development environments, especially with Windows Vista and virtual machines that you access by the Remote Desktop service.

Message and transport security should be applied after you get your app running on the server with basicHttpBinding, which implements the Web Service Interoperabilty (WS-I) Council's Basic Profile 1.1 Second Edition. You can change to WsHttpBinding by entries in host and client configuration file(s): app.config, AppName.exe.config, or web.config).

Fighting the Attached Associated Objects Bug

There is a serious bug in LINQ to SQL Beta 2 that causes invocation of the Table<TEntity>.Attach() method or its Table<TEntity>.Attach(ModifiedEntity, OriginalEntity)overload to correctly attach the root object as unmodified but perform inserts on the persistence tables for all associated entities that are equally unmodified. The bug was originally reported by an anonymous developer as Feedback 295402 Incorrect Update Behavior - Attaching an Entity after Calling a Relationship Property of 8/27/2007, which was closed as [to be] Fixed on 9/5/2007. Here's what C# program manager Alex Turner says about the bug:

Thanks for reporting this issue you've encountered with Visual Studio 2008! We were able to reproduce your issue after all! It turns out that our Attach() logic was adding the single attached object (the Product) to the object cache, but not any related objects (the Category) that had not been in the DataContext's object graph before. When SubmitChanges() found these objects, it did not know about them and thus assumed they had been added since the last query (otherwise the DataContext would have been the one to have materialized them and they would be known). We've now added an intermediate state for such objects that are related to attached objects so that they are assumed to already exist in the database (just like the attached object itself), and they will not be inserted during SubmitChanges. If you later add more related objects after Attach, they will be considered new objects as normal and queued for insertion.

Obviously there is no way that any two-level parent-child UI, such as the test harness below, could be considered close to operable with this problem.

Note: What's interesting about this third "intermediate state" is that Hibernate has three object states: Transient, Persistent, and Detached (see the diagram in section 4.1.1 transient objects on page 140 (Chapter 4) of Hibernate in Action by Christian Bauer and Gavin King (Manning, 2005). Hibernate has an evict() methodmethod to detach objects from the Persistent (attached) to the Detached state, whereas LINQ to SQL has no Table<TEntity>.Detach() method.

This is a client test harness for a self-hosted WCF service that has a LINQ to SQL data access layer (DAL) which retrieves the Customer, Order and two Order_Details entities from the persisting store. Changes have been made to the ContactName (Bogus -> Bogosian), EmployeeID (1 -> 2), and ProductID (1 -> 3 and 2 -> 4) property values:

Click image for full-size screen capture.   

Here's the result of invoking SubmitChanges() with the above edits. Instead of applying changes to the OrderID 11217 Order entity and its two Order_Details entities, attaching the root entity adds a new Order 11218 with two new Order_Details entities having the modified ProductID values:

Click image for full-size screen capture.   

Note: Rick Strahl reported the same bug in his Complex Detached Entities in LINQ to SQL - more Nightmares post of October 1, 2007 and suggested a workaround. I intend to test Rick's approach and will update this post with the result.

Incentives for Use of WCF for Serializing Business Objects

.NET Framework 3.0 added support for Windows Communication Foundation (WCF), together with Windows Presentation Foundation (WPF) and Windows Workflow Foundation (WF) to .NET Fx 2.0 and Windows Vista. .NET Fx 3.5 adds a few new features to these three technologies. WCF, formerly code-named Indigo, replaces conventional ASP.NET (.asmx) Web services, Web Services Extensions (WSE), .NET Remoting and Enterprise Services with a unified distributed communication technology.

WCF's Serialization Peformance

WCF provides significant performance improvements over the technologies it replaces. So it's a good bet that all .NET developers who attempt to maintain partition their object/relational mapping (O/RM) applications into multiple tiers will attempt to use WCF and XML serialization for messaging across process boundaries. WCF also enables more efficient (and thus performant) binary serialization for intranet applications that don't traverse firewalls.

The DataContractSerializer

WCF provides the DataContractSerializer (DCS) as an optional replacement for the traditional XmlSerializer of .NET Fx 2.0 and earlier. According to Microsoft UK's James World, DCS adds these features:

  • Hooks are providing for refining control of (de)serialization - particularly useful for handling versioning issues. By applying any of four special attributes to methods in the target class you can have them called either before or after (de)serialization.
  • The serializer is "opt-in" rather than "opt-out" - which makes (imho) for much cleaner code. In XmlSerializer you could use XmlIgnore to have the serializer ignore certain properties. With the DCS you explicitly mark what you want to serialize.
  • Finally, ANY field or property can be serialized - even if they are marked private.

The "four special attributes to methods" are the following DataContractSerializer properties:

  • MaxItemsInObjectGraph is a configurable property that "specifies the maximum number of items allowed in an object." The default is 65,536 (0x7FFF). Documentation says the units are bytes, which conflicts with the term Items. 
  • IgnoreExtensionDataObject is a configurable property that "gets or sets a value that specifies whether to send unknown serialization data onto the wire. The default value is false. Setting the value to true doesn't make the ExtensionData property disappear; it just prevents sending data, if any exists, to the client. 
  • PreserveObjectReferences is a non-configurable property that "gets a value that specifies whether to use non-standard XML constructs to preserve object reference data," specifically EntityRefs. The default value is false.
  • DataContractSurrogate is a non-configurable property that's "designed to be used for type customization and substitution in situations where users want to change how a type is serialized, deserialized or projected into metadata." 

You can set configurable property values in a configuration file (app.config, AppName.exe.config or web.config) or code in the WCF host application; setting non-configurable properties requires code.

Working Around the Cyclic Relationship Problem

If you must persist both m:1 and n:1 associations, you can patch your host code to set the PreserveObjectReferences property value to true, but doing so adds non-standard <id> and <idRef> elements to the message body. Sowmy Srinivasan provides a code example for Preserving Object Reference in WCF (March 26, 2006) that you can add to pass an instance of the DataContractSerializer with the PreserveObjectReferences property value to true to the WCF runtime for both server and client components. Microsoft's WCF team wants to discourage users from XML-encoding cycles, so you must write a custom behavior instead of setting an attribute value for the PreserveObjectReferences property value. (According to Aaron Skonnard, the same is true for substituting the NCDS for CDS.)

Stay tuned for Part 2, which will cover the code required to add, update and delete a top-level entity that might work as expected in the Visual Studio 2008 RTM version.

Updated 8/10/2007: Minor additions and clarifications.

Tech*Ed Developers 2007 to Include 10 LINQ-Related Presentations

Getting the details on LINQ-related presentations at Tech*Ed Developers 2007 Barcelona, being held November 5 - 9, 2007, requires signing in to the EMEA Events site. To save you the trouble, here are descriptions of the 10 presentations that include LINQ in their abstract. Presenters include LINQ Luminaries Luca Bolognese, Mike Taulty, and Bart De Smet.

TLA06-IS LINQ to “X”, ADO.NET Entity Framework, DataSets & Co – What is it with all these Data Access Technologies? 

Mike Taulty, Pablo Castro, Elisa Flasko, Carl Perry, Luca Bolognese

With the release 3.5 of the .NET Framework Microsoft introduced several new data access technologies based on its LINQ technology such as LINQ to SQL or LINQ to DataSets. About 6 months later we expect Microsoft to release the ADO.NET Entity framework together with LINQ to Entities. And finally we have all the existing ways for accessing data in different data storages shipping with the ADO.NET foundation such as DataSets, DataReaders and SQL-classes. Of course that raises one important question: Which data access technology is best suited for which situation? In this interactive session you get the chance to present your requirements and discuss, which technology fits best to your requirements – with members of the product teams themselves. Bring your ideas and requirements and discuss them with our experts!

Thu Nov 8 13:30 - 14:45 TBC

TLA07-IS Microsoft Visual C#: Tips and Tricks for the Microsoft Visual Studio 2008 and C# 3.0 IDE 

Luke Hoban

Through the releases of Visual Studio, the Visual C# team has focused on making the IDE more “code-focused” than ever before. Join Luke Hoban (Program Manager in the Visual C# team) in building an end-to-end application using C# 3.0 and Language Integrated Query (LINQ) that leverages a number of tips and tricks in the IDE to make the Visual C# developer more efficient and productive when trying to understand and write code. This presentation is highly demo-focused; learn innovative tips and tricks from leveraging existing IDE features in Visual Studio that will make you more productive today to leveraging new IDE support for understanding how to work with C# 3.0 and LINQ.

Wed Nov 7 10:45 - 12:00 TBC

TLA308 LINQ to SQL: Accessing Relational Data with Language Integrated Query  

Luca Bolognese

Database-centric applications have traditionally had to rely on two distinct programming languages: one for the database and one for the application. In this session we will introduce LINQ to SQL, a component of the LINQ project designed to help integrate relational data and queries with C# and Visual Basic. LINQ to SQL enables developers to express queries and updates against the SQL Server family of databases in terms of their local programming language without sacrificing the server-side execution model of today's high-performance SQL-based approaches. Using these advances, database queries that previously were stored as opaque strings now benefit from static type checking, CLR metadata, design-time type inference, and of course IntelliSense. LINQ to SQL also supports a rich update capability that lets you save changes to an object graph back to the database using optimistic concurrency or transactions.

Tue Nov 6 10:45 - 12:00 TBC

TLA309 LINQ to XML: Using the Language Integrated Query (LINQ) Framework with XML Data 

Mike Taulty

XML developers have had to learn a combination of APIs and query languages in order to work effectively with XML. In this talk we will introduce Language Integrated Query (LINQ) to XML, a component of the LINQ project designed to improve XML data programmability from C# and Visual Basic. LINQ to XML allows developers to load, query, transform, and update XML data using modern, easy to use programming features, and don’t require knowledge of related technologies such as DOM, XPath, XSLT, and the details of namespace binding. This presentation will present the high points of the LINQ to XML API, show how it extends the LINQ query operators to work with XML data, and work through realistic examples that show how processing XML data can be less painful, and almost fun.

Wed Nov 7 09:00 - 10:15 TBC

TLA311 Microsoft Visual Basic: Tips and Tricks for the Microsoft Visual Studio 2008 IDE  

Jay Schmelzer

In this session, we combine some tips for existing Visual Studio features, and tricks for leveraging new Visual Studio 2008 features. We look at a variety of existing features including operator overloading, refactoring, creating your own snippets, some tips for using frameworks classes (and generics), and leveraging application settings. Then we look at new features including some LINQ Do’s and Don’ts, My Extensibility, and taking control of unit testing in Visual Studio. All of these tips are aimed at giving you a more productive, fun programming experience.

Fri Nov 9 09:00 - 10:15 TBC

TLA312 Microsoft Visual C# Under the Covers: An In-Depth Look at C# 3.0  

Luke Hoban

This session provides an in-depth walkthrough of the new language features in Visual C# 3.0. Understand how features like extension methods, lambda expressions, type inference, anonymous types, and query expressions extend the C# language and enable Language Integrated Query (LINQ) on .NET. It is suggested that you attend the session "The .NET Language Integrated Query Framework Overview" before attending this session.

Tue Nov 6 15:15 - 16:30 TBC

TLA315 Provide Managed Extensibility in Your Products with Visual Studio Tools for Applications (VSTA) 2.0 

Thomas Quinn

Visual Studio Tools for Applications (VSTA) is a .NET-based application customization technology that can be embedded into applications to enable developers to create custom experiences on top of their products. For those familiar with Visual Studio Tools for Office (VSTO), it is built upon the foundation of VSTA. Understand what VSTA is and how the features of VSTA enable ISVs to build robust managed customization solutions that are secure and version-resilient. VSTA 2.0 built on System.AddIn will deliver powerful new features such as ClickOnce deployment for customizations, a dynamic programming model that makes it easy for developers to interact with the object model, as well as support for LINQ, Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and Windows Workflow (WF).

Thu Nov 8 17:30 - 18:45 TBC

TLA318 The .NET Language Integrated Query (LINQ) Framework

Luca Bolognese

Modern applications operate on data in several different forms: Relational tables, XML documents, and in-memory objects. Each of these domains can have profound differences in semantics, data types, and capabilities, and much of the complexity in today's applications is the result of these mismatches. Luca Bolognese, LINQ Lead Program Manager, explains how Visual Studio 2008 aims to unify the programming models through LINQ capabilities in Microsoft Visual C# and Visual Basic, a strongly typed data access framework, and an innovative Application Programming Interface (API) for manipulating and querying XML.

Mon Nov 5 17:45 - 19:00 TBC

TLA326 LINQ to Entities – Use LINQ to access ADO.NET Entity Data Models  

Mike Taulty

Most .NET database applications out there use ADO.NET to access and manipulate data, and most of them have a data-access layer built on top of ADO.NET to abstract out many of the details related to data-access that can get in the way of business logic. In this session we’ll introduce the ADO.NET Entity Framework, a high-level data library that pushes up the level of abstraction application developers need to work at when dealing with data in databases. We’ll discuss how the system supports conceptual modeling, the use of the object services layer to do object-relational mapping, and how great integration with LINQ (Language Integrated Query) brings new levels of productivity to the data-access development space. It is suggested that you attend "The .NET Language Integrated Query Framework Overview" before attending this session.

Wed Nov 7 13:30 - 14:45 TBC

TLA405 Parallel and Asynchronous Functional Programming on .NET with F#  

Don Syme

Functional programming a hot topic: there is a growing awareness of functional techniques in the developer community, and people are beginning to see that imperative OO programming has deep limitations in a networked and concurrent multi-core world. This session will use the research language F# to explore how declarative and functional techniques are relevant to these new programming challenges. F# includes constructs called asynchronous workflows that help you tame the complexity of asynchronous and parallel programming. We’ll look at how to use these how they relate to LINQ and Haskell. We’ll also look at some basic programming with F#, including how you can use F# to explore functional design patterns that are highly relevant no matter which language you’re working in.

Fri Nov 9 13:30 - 14:45 TBC

LINQ and Entity Framework Posts for 10/5/2007+

Jim Wooley Demos WCF 3.5's SyndicationFeed Feature for RSS/ATOM Feeds

Jim's October 12, 2007 Adding RSS posts to ThinqLinq using System.ServiceModel.Syndication.SyndicationFeed post demonstrates the progression of a VB 9.0 LINQ to SQL application that uses LINQ to XML to persist objects from RSS feeds to a database:

  1. Query the feed document and use a For Each loop and invoke the DataContext.Add() method to insert each object into the DataContext. Finally apply the DataContext.Submit() method to persist the collection.
  2. Early-bind element names and execute a LINQ query to generate an IEnumerable(Of PostItem) collection of projections created with object initializers. This eliminates the need for the For Each loop.
  3. Substitute SyndicationFeed.Load(Uri) for XDocument.Load("URL") to obtain a strongly typed object model that handles RSS and ATOM formats interchangeably.

System.ServiceModel.SyndicationFeed is a new Windows Communication Foundation feature in .NET 3.5's System.ServiceModel.Web namespace.

Added: October 12, 2007, 0930 PST

Erick Thompson Finally Describes LINQ to DataSet's LinqDataView Object

Erick provided a brief review of databinding with LINQ to DataSet in his LINQ to DataSet – Data Binding post of August 24, 2007 and promised to "be digging into more detail soon." Almost a month and a half later, he posted LINQ to DataSet Data Binding – Introducing LinqDataView on October 5, 2007, but I missed it. Thanks to the ADO.NET team who added a LINQ to DataSet DataBinding post today with a pointer to Erick's earlier post, which probably wasn't what they intended, I caught the October 5 post.

LinqDataView is an internal object from the System.Data.DataSetExtensions namespace that inherits DataView and implements LinqDataView, IBindingListView, IList, ICollection, and IEnumerable. Implementing the IBindingListView interface enables advanced (multi-column) sorting and filtering, as mentioned in my September 7, 2007 Support Sorting and Filtering for List<T> Collections post. You create a LinqDataView instance when you invoke the AsDataView() method on a LINQ to DataSet query.

Erick recommends using the LinqDataView for databinding UI controls and fast indexed lookup operations.

Erick says his "next post will talk about restriction joins and leveraging the index for fast lookups." Let's hope it comes a bit quicker than this one.

Earlier LINQ to DataSet references from LINQ and Entity Framework Posts for 9/7/2008+:

  • Andrew's Science Project post of September 7, 2007 includes the source code for a LINQ to DataSet extension method that removes the CopyToDataTable<T> method's restriction of the generic T type parameter to DataRow. The extension method enables loading instances of anonymous types into DataRows.
  • Daniel Moth has a July 27, 2007 LINQ to DataSet item with details of the classes in the System.Data.DataSetExtensions namespace.
  • Here are links to Erick Thompson's three introductory LINQ to DataSet posts from February 2007: Part 1, Part 2 and Part 3.

Added: October 12, 2007, 0930 PST

Frans Bouma Moves from Days to Parts and Admits Matt Warren Was Right About Sets

In Developing Linq to LLBLGen Pro, part 6 of October 12, Frans recounts at length a misstep when attempting to "outsmart the algorithm of Topological Sorting in a Directed Acyclic Graph (DAG)."

Object graphs are DAGs and Frans mentions that "cycles in relational models which are reflected in entity models is a Bad Thing and typically have to be redesigned." I mention the issue with cycles in serializing entities generated from LINQ to SQL that have both m:1 and 1:n associations in my LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1 of October 9, 2007.

Update October 15, 2007: Frans clarifies in a comment that he's referring specifically to cycles in relational models rather than cycles in related object graphs. The latter topic is one of the subjects of my XML serialization issues posts.

Frans then equates his earlier DAT and Topological Sorting foible with the requirements for handling a multiplying number of special cases in his previous (day 5) post, concludes that Matt Warren's following recommendation in a comment to use sets was right.

Dinesh Kulkarni Compares Capabilities of SqlMetal, the O/R Designer and Code

Dinesh is on a blogpost roll with a second post in two days. His LINQ to SQL: features not in the designer / SqlMetal post is dated October 9, 2007 but didn't show up on my reader until this morning. The article covers design features that:

  1. You can implement with SqlMetal.exe but not the graphical O/R Designer
  2. You can implement with the graphical O/R Designer but not SqlMetal.exe
  3. You can't implement with SqlMetal.exe nor the O/R Designer and require writing code

Dinesh mentions two items under category 3:

    1. POCO (Plain Old CLR Objects) - this is worth another blog post
    2. User overrides (e.g. sprocs) for relationship loading

My Save Server Round Trips by Preloading LINQ to SQL EntityRefs post of October 1, 2007 describes how to minimize round-trips and limit the size of associated EntitySets.

Added: October 11, 2007, 0930 PST

Joe Cheng Solves the Wide Finder Problem with LINQ and PLINQ

Tim Bray's Wide Finder Project originated as an exercise to improve the performance of a small Ruby program that reads Apache logfiles, applies a regular expression, counts, sorts, and finally prints the 10 most popular blog posts. The challenge is to take advantage of the CPU's multiple cores by using parallel processing to improve performance.

Joe Cheng, a developer on the Windows Live Writer team, posted on October 2, 2007 Wide Finder with LINQ, which contains a compact LINQ query with a few lines of C# code that beats the performance of the Ruby by a couple of seconds when reading a million-line logfile.

A pure C# version beat the LINQ query by a couple of seconds, but required 85 lines of code. As Joe notes, the LINQ version has the potential to use Parallel LINQ (PLINQ) from the forthcoming Parallel FX Library to improve performance.

See the "Luke Hoban Gets the Most Complex LINQ Query Award (and PLINQ Compatibility)" topic of my LINQ and Entity Framework Posts for 10/2/2007+ post, which describes the Parallel FX program and task parallel library:

The obvious advantage of moving from "conventional" C# 3.0 constructs to a single LINQ query is Parallel LINQ (PLINQ, which is part of the Parallel FX or PFX program) compatibility for simplified parallel processing on multi-core machines. There's a substantial Microsoft team at work on PLINQ and the October 2007 issue of MSDN Magazine carries a "Running Queries On Multi-Core Processors" story about PLINQ by Joe Duffy and Ed Essey.

Joe plans to release a PFX CTP in 2007. Watch his blog for details.

Daan Leijen and Judd Hall describe the more complex forthcoming Task Parallel Library (TPL) in an "Optimize Managed Code For Multi-Core Machines" article in the same issue. The C# 3.0 ray-tracer version upgraded with TPL will be an sample application in the PFX CTP.

Joe promises to publish performance data when Microsoft releases the Parallel FX Library.

Note: Don Box published in Wide Finder in C# - the Naive implementation of October 9, 2007 a more complex LINQ query that reads a stream from the logfile but appears to be slower than Joe Cheng's version (which Don cites in a ednote update.)

Credit: I use Windows Live Writer to author this blog. My review of the first beta version is Windows Live Writer (Beta) Blogger Test-Drive of August 14, 2006.

Added October 11, 2007, 0800 PST: I found this jewel thanks to Tim Bray's WF IX: More, More, More post of October 10, 2007)

Beth Massi Conducts Channel9 Sync Services Interview with Milind Lele

This blog also covers SQL Server CE and Microsoft Synchronization Services (a.k.a. Occasionally Connected Systems or OCS) topics, which don't see as much action as LINQ and the Entity Framework. Milind is a program manager on the VB Team, so you get to see some VB code instead of Sync Guru Rafik Robeal's C#-only samples.

You can catch the interview here.

Backstory: Mary Jo Foley's Microsoft ‘Arrowhead’ to up support for ‘occasionally connected’ apps post of October 10, 2007 makes this Sync Services/OCS interview more interesting. Apparently, Microsoft wouldn't respond to Mary Jo's "How does Arrowhead dovetail with Microsoft’s current offline synchronization platform, ADO.Net Sync Services?" query.

Sync Services gained considerable momentum at Microsoft after Google launched Google Gears. See my Google Gears Piques New Interest in Data Synchronization post of June 7, 2007.

Updated: October 11, 2007, 1300 PST

Julie Lerman Describes How to Customize Your Astoria Data Source

Her Custom Operations and hiding entities in Astoria post of October 10, 2007 shows how to "customize your service by providing explicit query operations and also blocking specific query operations." She also notes that you can build read-only views into the service, but you'll have to "wait wait until we have bits that are not just prototype" to learn how to enable stored procedures. 

Added: October 10, 2007, 1230 PST

Mike Taulty Implements an Unbound DataContext in a WCF Client

My updated version of the LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1 post mentions Mike Tulty's displeasure (which I share) with the tedium of writing code to clone and save original values to implement value-based concurrency conflict management. So Mike described in his LINQ to SQL and WCF - Sharing types, subverting the DataContext on the client side post of October 9, 2007 how to implement in a Windows Communication Foundation (WCF) client a DataContext class that's not bound to a database. The starting point is client and service described in his initial Disconnected LINQ to SQL post of September 14, 2007.

The unbound DataContext provides Attach(), AttachAll(), Add(), AddAll(), Remove()and RemoveAll() methods for Table<TEntity> implementations of the ITable interface and stores the original and changed entity values. You apply changes to the attached entities directly. The Table<TEntity>.GetModifiedMembers() method contains references to added, removed, and modified members.

Invoking Mike's GetInserted(), GetModified() and GetDeleted() methods supply modified argument values to InsertEntity(modified, original) and UpdateEntity(original, modified) service methods. The Table<TEntity>.GetOriginalEntityState() method provides original argument values to the preceding two service methods, plus the DeleteEntity(original, modified) method. (DeleteEntity() requires both arguments because you must attach the entity before you remove it.)

Mike includes a simple client console app to test his methodology, which he says "is really a bit subversive and possibly a bit evil."

What's interesting about this approach is its similarity to Matt Warren's promised "mini connectionless DataContext" that I discussed in my Changes Coming to LINQ to SQL post of May 15, 2007. This article resulted in a long LINQ: Next CTP thread in which Matt Warren reneged with these two posts:

No, this feature will not be in the first release of LINQ to SQL. ...

It is only missing because of lack of time.  When I mentioned it, I was talking about our forward thinking and a sample I'm trying to put together.

WCF's proxy generation tool creates the client-side classes that Mike includes in his DataTypes class library generated by executing sqlmetal.exe /server:. /database:northwind /serialization:Unidirectional /pluralize /code:northwind.cs, with these exceptions:

  • The proxy classes don't implement the INotifyPropertyChanging interface.
  • The class library doesn't add the ExtensionData property to the entities.

Neither of the above problems should be fatal, so I'll give Mike's approach a test with the C# version of the test harness described in yesterday's LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1 post and report my results.

Note: Mike uses the terms Shared Contract and Shared Types differently than the WCF team. Sowmy Srinivasan describes the difference between the two terms in his All About KnownTypes post of June 06, 2006 by how they're serialized on the wire. Aaron Skonnard discusses the history of WCF SharedContract and SharedType modes in his WCF's NetDataContractSerializer post of April 21, 2006. Services that use the default DataContractSerializer implement the SharedContract mode.

Added: October 10, 2007, 1100 PST

Update October 11, 2007: Mike's DurableServices in WCF V3.5 :-( post today indicates to me that he's working on another approach or a supplement to maintaining context with WCF features akin to Durable Services.

Update October 14, 2007: Corrected service method names and clarified client-side operations in conjunction with the

Dinesh Kulkarni Links to Breaking Changes from LINQ to SQL Beta 2 to RTM

Apparently Dinesh doesn't believe that folks are checking posts in the LINQ Project General forum, so he added in his LINQ to SQL breaking changes from beta2 to RTM (compiled from my LINQ forum posts) post of October 9, 2007 links to his three previous posts on the subject:

I can only assume that these two important changes not included in the preceding list won't beak Beta 2 code:

because Dinesh didn't mention them in his post or the liked threads.

Added: October 10, 2007, 1200 PST

Eric White Summarizes Changes to LINQ to XML from Beta1 to Beta2 and RTM

Not to be outdone by the LINQ to SQL team, Eric White's October 9, 2007 Upcoming changes in LINQ to XML post lists four changes between Beta 1 and Beta 2 and three more coming up in RTM.

Added: October 10, 2007, 1200 PST

Beth Massi Links to Scott Hanselman's Audio Podcast about LINQ to XML

Scott Hanselman recorded on August 31, 2007 a <LINQ to XML/> Hanselminutes podcast that's hosted by Carl Franklin.

Beth announced that she'll present Conquering XML with LINQ in Visual Basic 9.0 at the QCon Conference in San Francisco (see QCon 2007 and Erik Meijer Coming to San Francisco November 7 - 9 of August 2, 2007.)

There's a list of 14 LINQ to XML resources and she also promises future "How Do I?" LINQ to XML videos at the bottom of her Scott Hanselman on VB9's New "XML Hotness" post.

Added: October 10, 2007, 1230 PST

LINQ to SQL and Entity Framework XML Serialization Issues with WCF - Part 1

This post introduces the issues I encountered when attempting to create a sample application that illustrates interactions between a real-world, data-bound Windows client, Windows Communication Foundation (WCF), and LINQ to SQL data access layer (DAL).

The post deals with the full lack of object-graph schema fidelity to the original entity's properties. You lose Attached Associated Objects Bugs for m:1 associations if your object has EntitySets for 1:n associations that share a common property.

There's also a graphic example of the "Attached Associated Objects Bug" that duplicates associated entities when attaching a Table<TEntity>  object that has EntitySet properties to a DataContext.

Added: October 9, 2007, 1700 PST

Matt Warren Tackles the Four OrderBy Flavors in Part VIII of His Building an IQueryable Provider Saga

LINQ: Building an IQueryable Provider - Part VIII begins with Matt's observation:

Fortunately, there is only one way to do ordering, and that's using the LINQ ordering specific query operators. The bad news is that there are four different operators.

Matt then runs into (and around) corners resulting from the immutability of expression trees and devises an amazing OrderByRewriter class that he describes as "a whole lot of something!" to handle what appears to be this simple LINQ query:

var query = from c in db.Customers
    orderby c.City
    where c.Country == "UK"
    select new { c.City, c.ContactName };

As usual, the source code is available to download.

Added: October 9, 2007, 1700 PST

"Leverage LINQ in ASP.NET 3.5 Projects" Available for Download from WROX

My Leverage LINQ in ASP.NET 3.5 Projects article is one of four inaugural Wrox Blox downloadable "informational pieces" that "help get you up-to-speed and keep you up-to-date" plus "build the knowledge you need quickly on a wide variety of topics."

For $3.99, you can download the 38-page tutorial and it's accompanying C# and VB source code for a complete LINQ to SQL data access layer (DAL). The DAL binds to a LinqDataSource or ObjectDataSource control and an updatable GridView control on ASP.NET 3.5 pages. (The source code requires Visual Studio 2008 Beta 2 or later and the Northwind sample database installed on an SQL Server 2005 Express instance.)

You can add a new "BOGUS" Customer entity with code, edit its properties in the grid, and delete the entity without affecting your original Northwind Customers table's contents.

Click image for full-size screen capture.

The source code for the LinqDataSource and ObjectDataSource test harness is available here.

Added: October 9, 2007

Update October 9, 2007: Wrox Blox editor Jim Minatel offers more details on the new format in Wrox Blox launches with Silverlight, Adobe AIR, IPhone and LINQ and announces Wrox's ASP3wiki, the second Wrox electronic product to launch this week.

Catch 10 LINQ-Related Sessions at Tech*Ed Developer 2007

Tech*Ed Developers 2007 to Include 10 LINQ-Related Presentations includes abstracts and presenter names of the 10 sessions in Tech*Ed 2007 Barcelona being held on November 5 - 9, 2007. LINQ Luminaries Luca Bolognese, Mike Taulty, and Bart De Smet are among the presenters. This post eliminates the need to register to open and search the EMEA Events page for the conference.

Added: October 9, 2007

Dinesh Kulkarni Addresses Attach()/Detach() Confusion in LINQ to SQL Projects

Dinesh's Attach() if you have something detached post of 10/8/2007 attempts to clear up the confusion surrounding use of the DataContext.TableName.Attach() method in stateless ASP.NET and Windows Communication Foundation (WCF) service projects. Dinesh attributes much of the confusion to the term detached object support, which he characterizes as a "misnomer." As an example, Dinesh cites

  • 8. Streamlined and enhanced support for detached objects (see Attach() APIs) for multi-tier apps

in his LINQ to SQL (fka DLinq): What's new in Orcas beta2 post of July 26, 2007. This post appears to be the result of the quest for a:

  • 6. A story for detached object - this is handy for stateless situations like ASP.NET, web services etc.

which appears to have been the most favored DLinq feature from Dinesh's DLinq: What's cooking in the kitchen post of March 16, 2006.

Java's Hibernate and .NET's NHibernate object/relational mapping (O/RM) tools offer detached object support. Here's the definition from Sun Microsystems' J2EE Persistence: Explore Your Persistence Options presentation by Sang Shin:

  • Detached Objects – Instances that lose association with persistence manager when you close() the session
  • Hibernate allows for selective reassociation of a subgraph. [For example,] you may serialize objects to the web tier, then serialize them back to the EJB tier in the next request.
  • Reference to detached object outside of a transaction/persistence manager can be
    retained and reassociated with a new persistence manager.

Note: For more about detached objects in Hibernate, see section 4.1.3 Detached objects on page 142 (Chapter 4) of Hibernate in Action by Christian Bauer and Gavin King (Manning, 2005).

Hibernate and NHibernate are mature, widely used, and the standard of comparison for O/RM tools. What's interesting is that LINQ to SQL doesn't support selective reassociation of a subgraph or reassociation with a a new persistence manager. Reassociation appears to be explicitly verboten (by exception) in the RTM version.

Perhaps the confusion about detached objects arises from differences in definition between LINQ to SQL and Hibernate.

Another source of confusion might be the bug in LINQ to SQL Beta 2 that causes entities associated with a newly-attached root entity to be inserted rather than assumed to be persisted in the database and awaiting update. For more details, see Feedback: Incorrect Update Behavior - Attaching an Entity after Calling a Relationship Property of August 27, 2007 (resolved as fixed on September 5, 2007) and Rick Strahl's Complex Detached Entities in LINQ to SQL - more Nightmares post of October 1, 2007. If the LINQ to SQL team delivered their long-promised sample project to demonstrate LINQ to SQL with WCF services, they might have discovered the issue before locking down the Beta 2 bits. (This assumes that the example included associated entities, which seems to be uncommon in sample projects.)

Note: See sample WCF project issues with LINQ to SQL and Entity Framework in my "From the 'Talk is Cheap' Department" subhead of the "Julie Lerman Demonstrates Detached Updates with Entity Framework" of LINQ and Entity Framework Posts for 9/28/2007+ post.

Stay tuned for a LINQ to SQL/WCF test harness that demonstrates this bug.

Added: October 9, 2007

Julie Lerman on Persisting Entity Framework Object Graphs in ASP.NET ViewState

Julie's Entity Framework object graphs and viewstate of October 5, 2007 confirms that Entity Framework object graphs can be binary-serialized into an ASP.NET page's Viewstate property value. Unlike with conventional XML serialization, which ignores associated objects,  Viewstate preserves associations but not root object state. ObjectContext (like DataContext) objects can't be serialized.

Julie also discovered that viewstate synchronizes object updates:

One saving grace is that objects stored in viewstate get updated automagically during postback. In other words, if I create a cust object and store it in viewstate, then make a change to the cust object, then postback and pull the object back out of viewstate, it will have the newer property values. Viewstate is synced up to the object.

I'm sure we'll hear more on this topic after Julie delivers her Accessing Data Services in the Cloud with Astoria presentation to REMIX07 Boston today (2:30 - 3:45 p.m.)

Added: October 9, 2007

Dom Demsak and LINQ to XML Parts 1 and 2 on DNR TV

From the "How Did I Miss This" Department

Dom Demsak (DomXML) recorded two episodes of "Dom Demsak and LINQ to XML" for Franklins.net's DotNetRocks TV:

Don lists his "great takaways" from the series in his .Net Rocks - XML Literals - You Got VB In My XML post of September 11, 2007.