Note: Items about the Frans Bouma and Pablo Castro articles that were entered on 9/28/2007 have been moved to LINQ and Entity Framework Posts for 9/28/2007+.
Guy Burstein Compares LINQ to SQL's Attribute- and XML-Based Mapping
Guy's September 23, 2007 Linq to SQL Attribute Based Mapping post avoids the O/R Designer and leads you through the process of writing your own LINQ to SQL class files with [Table(Name="TableName")], and [Column(Name="ColumnName"), IsPrimaryKey=true, IsDbGenerated=true), CanBeNull=false] attributes.
His September 27, 2007 Linq to SQL XML Based Mapping post eliminates the need for decorating classes with attributes by writing an XML mapping schema document and loading an XmlMappingSource with instructions like:
XmlMappingSource mapping = XmlMappingSource.FromUrl("NorthwindMap.xml")
DataContext ctx = new DataContext(connectionString, mapping);
var query = from order in ctx.GetTable<Order>()
where order.CustomerId == "ALFKI"
foreach (Order order in query)
Console.WriteLine(order.Id + " " + order.OrderDate + " " + order.CustomerId);
XML mapping files skip business object classes altogether and let you execute LINQ to SQL queries against temporary Table<TEntity> objects directly.
Charlie Calvert Tackles Anonymous Types from C# LINQ Queries
Charlie's September 26, 2007 Anonymous Types in Query Expressions is an elementary discussion of anonymous types with samples from C# query expressions with the following topics:
- Using Anonymous Types
- Returning a Particular Class from a Query Expression
- Querying a Class You Can't Modify
Rick Strahl Designs Business Objects Over LINQ to SQL
Rick's September 26, 2007 LINQ to SQL Queries out of a Business Layer post describes a simple business object with methods that return the IQueryable<EntryEntity> type for execution in the LINQ to SQL data layer. This enables the UI layer to qualify the query with Where and/or OrderyBy operators that will be reflected in the IEnumerable<EntryEntity> result.
Danny Simmons and Persistence Ignorance Redux
If there's an Ignorance Quotient for Persistence Ignorance (PIQ?), you'd assume that 100% would indicate an object/relational mapping (O/RM) tool supporting business objects with no knowledge of or interest in their persistence mechanism. In that case, 0% would represent total dependence on a particular database for persistence, proprietary object attributes tied to the O/RM tool, and onerous base classes from which all objects must inherit.
Danny Simmons' EF Persistence Ignorance Recap post of September 26, 2007 provides a summary the current state of the Entity Frameworks PI for version 1.0, which the team expects to release in the first half of 2008. I'd give it a PIQ of about 20.
Danny also includes links to his previous articles on the topic. The primary OakLeaf PI post is Persistence Ignorance Is Bliss, but Is It Missing from the Entity Framework? of March 7, 2007. This post explains the origin and definition of PI and the controversy that erupted from the "NHibernate Mafia" at Microsoft's Most Valuable Professionals Summit held in Seattle and Redmond on March 12-15, 2007.
Chris Buckett Starts an Entity Framework Series
UK Developer Chris Buckett has started the series with an illustrated Entity Framework, Part 1 - The high level overview of September 25, 2007.
Chris also is a proponent of VistaDB, as he notes in this earlier VistaDB - .net managed database item. VistaDB has < 1MB file system footprint and is compatible with Visual Studio 2008 Beta 2.
Four More Astoria Posts by Julie Lerman
Julie is proving to be a fountain of information on little-known and underdocumented aspects of Astoria. Following are her last three posts of Saturday, September 22, 2007, in chronological order:
Deciding Astoria's Final URI Addressing Scheme
Taking Julie up on her request, I expanded the Deciding Astoria's Final URI Addressing Scheme item and moved it from here to its own URI.
Astoria Quick-Start from [Guess Who?]
Julie just posted a lavishly illustrated step-by-step QuickStart for building an Astoria data service from Northwind. She ran into a problem with ASPNETCompatibiltyEnabled in the web.config file, so her demo runs under Windows XP SP2. I'm trying it in Vista to see if I run into the same snag. [Unfortunately, my current Vista VMs are contaminated by previous Jasper installs.]
Julie Lerman to Present Sessions on Astoria at REMIX Boston and New England Code Camp
Julie's What the heck is Astoria? post of September 21, 2007 shows the basics of RESTful, URI-based data retrieval from a local Astoria Web Data Service. As she notes, the Web Data Service looks like a WCF Service and uses the Entities class from your Entity Data Model as its data source. Julie's presenting a session on Astoria at REMIX Boston 07 (10/8-9/2007) and at the New England Code Camp (9/29-30/2007).
Her resultsets are formatted as plain-old-XML (POX), which will be replaced by Microsoft's new Web3S XML format in a later CTP. Silverlight 1.1 has an Astoria client library; XML-formatted data is one reason that a future Silverlight version will include LINQ to XML.
Astoria also provides RESTful update semantics with HTTP PUT and POST operations. Here's a copy of Leonard Richardson's table of HTTP verbs as they apply to Astoria entities:
|EntitySet (Collection)||X||Create a New Entity|
|Scoped EntitySet||X||Create an Association between Two Entities|
The preceding LINQ and Entity Framework Posts for 9/14/2007+ post has links to additional Astoria content. My original post on Astoria, "Astoria" Enables RESTful Data Services of April 30, 2007, has links to several related articles and blog posts from MIX07.
RTM Change to LINQ to SQL's Default XML Property Type Mapping
Dinesh Kulkarni's Beta2 to RTM change: XML column default mapping changed to XElement instead of XDocument post of September 20, 2007, the default data type for entity properties mapped to SQL Server 2005+ columns of the xml data type will be XElement. Dinesh's post explains:
Reason: due to a late change in LINQ to XML, XDocument cannot be serialized with the DataContract serializer. XElement can still be serialized. We wanted to make sure that if you choose the serialization option in SqlMetal or designer, the resulting classes are indeed serializable. Hence, we have changed the default to XElement.
However, you can still choose to use XDocument explicitly in the designer or by editing the dbml (or in your favorite editor or separate mapping tool). It is just not the default anymore.
This is a breaking change. The following two forum posts noted in the LINQ and Entity Framework Posts for 9/7/2008+ item also describe breaking changes at RTM:
- LINQ to SQL Beta2 to RTM Key Changes (August 27, 2007)
- Beta2 to RTM Changes in Attach() Behavior (September 11, 2007)
Moving to LINQ to SQL RTM Will Require Design-Time Class Refresh
In the same September 20, 2007 post, Dinesh warns:
When moving from beta2 to RTM, please make sure that you regen the classes from your database/dbml using designer or SqlMetal. While we would have liked to maintain "generated source compatibility", that has not been possible in going from beta2 to RTM. I expect problems if code generated with beta2 is used against RTM version of System.Data.Linq.dll.
Note: Code added to accommodate differences between ISingleResult<T> and Table<TEntity> types returned when retrieving persisted data with stored procedures (see below), such as ToList<T> invocations, probably will continue to work but should be removed.
Changes in Store by RTM for LINQ to SQL's WinForm Databinding with Stored Procedures
My Upgrade to LINQ to SQL's WinForm Databinding with Stored Procedures Scheduled for RTM of September 19, 2007 describes the change from the ISingleResult<T> to the DataQuery<TEntity> type returned to the DataContext object by stored procedures that retrieve data. This means that populating DataContexts with stored procs will be closer to on par with dynamic SQL when Microsoft releases Visual Studio 2008. You'll probably hear more about this change from Dinesh Kulkarni in the near future. In the meantime, I'm anxious to hear from Scott Guthrie how the change will affect the LinqDataSource.
You can expect updates to (or a rewrite of) this and my earlier Problems Using Stored Procedures for LINQ to SQL Data Retrieval post shortly. The first update to this post, an added "DataQuery<T> and Table<TEntity> vs. ISingleResult<T> and List<T> Collections" section, is ready now.
This does not appear to be a breaking change but it will affect the LinqDataSource. (Updated 9/19/2007. Repeated because of its importance.)
Early Version of LINQ Provider for the db4o Object Database
Luciano Di Cocco has written "very primitive and limited implementation of a LINQ provider for db4o" called, unsurprisingly, LINQ to db40. db4o is an open-source object database that has Java and .NET implementations. including the .NET Compact Framework.