Showing posts with label InterLINQ. Show all posts
Showing posts with label InterLINQ. Show all posts

Saturday, February 16, 2008

LINQ and Entity Framework Posts for 2/11/2008+

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

Updated: 2/15/2008 for the Amazon S3 outage and 2/16/2008 for the reason for the outage. See the "Justin Etheredge Offers Preview of LINQ to [Amazon] SimpleDB" topic.

Danny Simmons Deals with the ObjectContext Lifetime Dilemma

Danny's Context Lifetimes -- Dispose or Reuse? post of 2/17/2008 (yes, a Sunday post) attempts to answer its title's question based on "understanding the overall pattern of your app." (Other than "too slow" I suppose.)

On the whole, Danny's criteria for reusing and disposing also can be applied to LINQ to SQL DataContext objects, which are lighter weight.

The question, which I've asked in the comments, is how will the (hopefully) imminent ASP.NET EntityDataSource server control affect the recommendations?

Added: 2/17/2008

David DeWinter Starts Project to Synchronize LINQ to SQL DBML Files with Database Schema Changes

David's LINQ to SQL and Database Schema Sync post of February 16, 2008 describes his objectives in starting a project to keep his "generated entity classes in sync with the current database schema" by a mechanism other than clearing the designer surface and starting over. He cites many types of manual adjustments to the entities in the designer that must be made to many tables each time you drop them on the designer surface. The goal is to maintain a record of systematic changes for repetition on both unchanged and altered or added tables.

His second The LINQ to SQL Metamodel post of the same day describes his use of Project NORMA to enable Visual Studio 2008 to render Object Role Modeling (ORM) diagrams of Database, Connection, Table, Type, Column, Association, Function and TableFunction elements. (Some of the diagrams are amazingly complex.)

Note: The Entity Data Model's Model Browser has a similar feature called Update Model from Database that opens the Entity Data Model Wizard that lets you select items to add. The Wizard automatically updates existing and deleted items. My tests so far with the Beta 3 version have resulted in non-displayable models.

Added and subscribed: 2/16/2008

Dare Obasanjo Seconds the ADO.NET Entity Data Team's Decision to Adopt AtomPub for Updates

In his ADO.NET Data Services (Astoria) Adopts AtomPub post of February 16, 2008, Dare says:

I'm glad to see Microsoft making a huge bet on standards based, RESTful protocols especially given our recent history where we foisted Snakes On APlane on the industry. [Emphasis Dare's.]

However since AtomPub is intended to be an extensible protocol, Astoria has added certain extensions to make the service work for their scenarios while staying within the letter and spirit of the spec.

Dare then goes on to analyze in his Thoughts on Google's Proposal for Granular Updates in AtomPub post of February 16, 2008 Joe Gregorio's How to do RESTful Partial Updates proposal of February 15, 2008 for updating specific properties of an entry without retrieving and returning the entire entry. Dare's primary complaints are:

The main problem is that it changes the expected semantics of HTTP PUT in a way that not only conflicts with how PUT is typically used in other HTTP-based protocols but also how it is used in AtomPub. It's also weird that the existence of xml:id in an Atom document is now used to imply special semantics (i.e. this field supports direct editing). I especially don't like that after all is said and done, the server controls which fields can be partially updated or not which seems to imply a tight coupling between clients and servers (e.g. some servers will support partial updates on all fields, some may only support partial updates on atom:title + atom:category while others will support partial updates on a different set of fields). So the code for editing a title or category changes depending on which AtomPub service you are talking to.

Dare's solution:

If a field is important enough that it needs to be identifiable and editable then it should be its own resource. If you want to make it part of another resource then use atom:link to link both resources.

Added: 2/16/2008

Julie Lerman Creates ADO.NET Data Services PopFly Mashup

Julie's presenting a Web Mashups with ADO.NET Data Services session at DevConnections, so she decided to create a PopFly mashup with the aid of the Popfly Explorer plugin for VS 2008 [Express].

She recounts her experiences creating a simple read-only client with the NewsReader block in her ADO.NET Data Services + PopFly post of February 15, 2008.

Added: 2/15/2008

Microsoft Appoints Scott Guthrie Corporate Vice President for the .NET Developer Platform

Scott received a well-deserved promotion in Redmond's latest management reshuffling, as noted in a February 14, 2008 press release, Microsoft Announces New, Expanded Roles for Key Executives. From the release:

Scott Guthrie, corporate vice president, .NET Developer Platform. Previously general manager, Guthrie will continue to oversee several development teams responsible for delivering Microsoft Visual Studio developer tools and Microsoft .NET Framework technologies for building client and Web applications.

Congratulations, Scott. Hopefully, the rise in grade won't stem the flow of your great tutorial and useful linkblog posts. As I said in a comment to Joe Wilcox's Microsoft Puts on Midlife Executive Bulge post of February 15:

Of all the execs whose titles Microsoft bumped up yesterday, not one deserves a promotion more than Scott Guthrie. Scott's enthusiasm for the .NET development platform, as evidenced in his blog and technical presentations, continue to attract programmers of all skill levels to Visual Studio 2008 and .NET 3.5.

Other developer-oriented groups would do well to clone Guthrie's approach to marketing their platforms.

Microsoft also boosted Scott's boss, S. "Soma" Somasegar, from Corporate to Senior Vice President:

S. Somasegar, senior vice president, Developer Division. Previously corporate vice president, Somasegar will continue to oversee all developer-related languages, tools and platforms within Microsoft. He also leads Microsoft India Development Center and Microsoft Canada Development Centre.

Added: 2/15/2008

Updated 2/16/2008: .NET Rocks! interviewed Scott for show #316 (2/14/2008) about IIS 7.0, Silverlight 2.0, MIX 08 and other hot topics. Scott's 34-minute segment starts at 04:00.

Justin Etheredge Offers Preview of LINQ to [Amazon] SimpleDB

Justin's been working on LINQ to SimpleDB since shortly after Amazon opened SimpleDB's limited beta. His LINQ To SimpleDB Issues post of December 31, 2007 (before he had access to the beta) details the issues with dealing with numbers when the database only supports strings. I've missed Justin's LINQ-related posts on his CodeThinked blog up until now because it doesn't have high visibility for "LINQ" in search engine results.

Justin released LINQ to SimpleDB Alpha 1 (source code and runtime binary) to CodePlex on January 23, 2008 under the Microsoft Public License (Ms-PL). His LinqToSimpleDB Preview post of January 19, 2008 offers operating instructions. The Releases page describes the included functionality as:

  • Query SimpleDB Items by Attributes
  • Retrieve Attributes for items
  • Query items by Name
  • Create and Delete Domains
  • Create and Delete Items
  • Create and Delete Attributes

Note: My Amazon Announces Beta of SimpleDB Web Services in the Cloud of Post of December 14, 2007 and Dare Obasanjo's Amazon SimpleDB: The Good, the Bad and the Ugly post of December 21, 2007 analyze SimpleDB's feature set.

I plan to give LINQ to SimpleDB a test drive as soon a SimpleDB beta test slot becomes available.

Added: 2/14/2008

Updated 2/15/2008: All Amazon Web services (including SimpleDB) appear to have suffered a massive outage at about 4:30 AM Pacific time according to Nicholas Carr's post of this morning. The problem was reported to have been corrected at 7:30 AM but some users were still reporting problems at 8:30 AM, according to Michael Krigman's Amazon S3 web services down. Bad, bad news for customers. blog, "Rearranging the Deck Chairs: IT Project Failures."

Amazon's Service Level Agreement for S3 (which presumably would apply to SimpleDB when it's out of beta) is 99.9% availability during a monthly billing period. Assuming 30.5 days/month, 0.1% downtime is 0.732 hours.

Updated 2/16/2008: Nick explains in today's Why S3 failed update that:

It was not a hardware failure. Rather, the service's authentication system, which verifies the identity of a user, became overloaded with user requests. As one person explained to me, it amounted to a kind of accidental DDoS (distributed denial of service) attack, and Amazon didn't have enough capacity in place in one of its data centers to handle the surge.

Nick's post includes the official reason in a message from Amazon.com.

Mike Taulty Tabulates Entity Framework's Mapping Capabilities

Mike's ADO.NET Entity Framework Mapping Table post of February 14, 2008 begins with:

One of the things that's been really bothering me for quite a while now is the aspect of mapping in the Entity Framework.

Technical things can trouble me. I like to get them into my head, understood and then I can move on. I have a very, very bad memory and the only way I can remember anything is by understanding how it works and then I find it relatively easy to piece back together at a later point.

Strange that Mike should mention this. I'm bothered by the same questions about EF's mapping capabilities, despite the fact that I use them almost every day. I also have the same memory problem. So Mike put together a list of these capabilities with details examples. Here's a list of what he covers:

  1. Renaming an Entity Type
  2. Renaming an Attribute (although I'd call it Renaming a Property)
  3. Removing an attribute (ditto)
  4. Specifying a default value for an attribute that does not have a default value
  5. Overriding a default value for an attribute that has a default value
  6. Changing the data type of an attribute
  7. Changing the nullability of an attribute
  8. Multiple store tables, single entity type
  9. Single store table, multiple entity types or entity sets

For all my sample projects that use EF/EDM, especially those based on Northwind, I use:

  1. To singularize Entity Types, leaving the Plural for Entity Collections/Sets
  2. To singularize the name of navigation properties for Many:1 associations
  3. To remove images (e.g., Category.Picture and Employee.Photo)

But I hadn't thought of using 5 to add Today as Order.OrderDate's default value or 7 to change the nullability of value-type properties, such as Order.OrderDate, Order.Freight, Product. UnitPrice, etc. The latter might solve some of my issues with EF projects in VB (e.g. performance problems with COALESCE and no support for the Coalesce operator by the VB version of ADO.NET Data Services clients -- see below). Minimizing Nullable<T> data types also minimizes Nullable`1[System.Decimal]" type declarations in ADO.NET Data Services' Atom-formatted payloads.

Update 2/14/2008: Default values are constants of the property's type, so specifying the DateAndTime.Today property doesn't work. (Nor does it throw an exception).

I'd say the preceding list would make a good start for a series of ADO.NET Team blog posts, as well as the final EF documentation.

Added: 2/14/2008

Pablo Castro: ADO.NET Data Services and the Atom Publishing Protocol

Pablo explains the Project Astoria team's approach to adopting the Atom Syndication Protocol (Atom, RFC 4287) and Atom Publishing Protocol (APP, RFC 5023) as data-exchange (payload) formats in his AtomPub support in the ADO.NET Data Services Framework post of February 13, 2008.

The Astoria Team plans to post its proposed extensions and application-level features for discussion on the atom-syntax and atom-protocol mailing lists. Read more about the pending issues here.

Added and updated: 2/14/2008

Tercer Planeta's Working on a LINQ-Enabled Application Framework

Jose Marcenario and Benjamin Eidelman, principals of Tercer Planeta (Third Planet, a .NET consulting firm in Argentina), have determined that "it would be great to have a LINQ 'Queryable' data access layer." So they've "started to analyze LINQ-to-SQL integration in Enterprise applications of different scale."

Benjamin's initial post, First Thoughts on Designing a LINQ-enabled Application Framework of February 13, 2008, deals with issues arising from LINQ to SQL's infamous lack of "an out-of-the-box n-tier story" because DataContext objects aren't serializable.

He points to Manuel Bauer's InterLINQ project on CodePlex that serializes an expression tree and returns the query result. (InterLINQ is destined to become a component of the poor man's Model Driven Architecture for .NET project from HSR Hochschule für Technik Rapperswil, Switzerland' .NET Competency department). However, it doesn't appear that Tercer Planeta will take the InterLINQ route.

At the end of the post, Benjamin says:

These days we're starting to see the light and the end of tunnel, with custom tools and code we started to write.

More on this on following posts...

Added: 2/14/2008

VB-Specific Bugs in ADO.NET Data Services CTP

Today's Fix for "Known Bug" when Creating ADO.NET Data Services with Visual Basic and a Web Application post updates an ASP.NET 3.5 Extensions Preview Released post of December 10, 2008 included a "Data Services (Project Astoria)" topic that itemizes some errors in the QuickStart instructions for creating an ADO.NET Data Service.

The need to do a fixup by removing the default namespace for a VB ADO.NET Data Services project that uses a ASP.NET Web Application (rather than a file-system Web site) turned out to be a known but unpublicized bug.

There's another VB-related bug that's described in my LINQ Query Expression Fails in VB with 'Coalesce' Not Supported Error, C# OK post in the ADO.NET Data Services (Pre-release) forum. I'm waiting for a reply indicating whether that problem is known.

While I'm griping, the numeric operators documentation shows lteq and gteq instead of the correct le and ge for <= and >=, respectively. There's also an issue with the use of $expand in LINQ to REST and WebDataQueries, which has known problems.

Errata for docs and lists of supported and unsupported operators, etc., would be very useful for ADO.NET Data Services pilgrims (like me.)

Added: 2/13/2008

Charlie Calvert: Using the Expression Tree Visualizer

The latest in Charlie's LINQ Farm Seed series is LINQ Farm Seed: Using the Expression Tree Visualizer of February 13, 2008. This post gives detailed instructions on how to download the visalizer and use it to view the expression tree for a simple lambda function.

Added: 2/13/2008

Julie Lerman Records Entity Framework Podcast for .NET Rocks!

Julie's Just recorded DotNetRocks about Entity Framework post of February 12, 2008 describes her one-hour interview with Carl Franklin and Richard Campbell about the Entity Framework.

A major concern voiced in her podcast: DBAs' reluctance to accept dynamic SQL queries from Entity Framework or LINQ to SQL and ignorance of both implementations' capability to use stored procedures for all CRUD operations.

Mark your calendars: The podcast will be aired on February 26, 2008.

Added: 2/13/2008

James Newton-King Publishes LINQ to JSON Beta

According to James' LINQ to JSON beta post of February 11, 2008, LINQ to JSON is an API that's similar to LINQ to XML, not a LINQ provider. It enables a declarative syntax for writing JSON code and a query syntax for reading it. The post provides a simple RSS channel/items structure as an example.

LINQ to JSON is part of James' larger Json.NET project on CodePlex. According to the project's home page, Json.NET offers:

  • Lightning fast JsonReader and JsonWriter
  • The JsonSerializer for quickly converting your .NET objects to JSON and back again
  • Json.NET can optionally produce well formatted, indented JSON for debugging or display
  • Attributes like JsonIgnore and JsonProperty can be added to a class to customize how a class is serialized
  • Ability to convert JSON to and from XML

Json.NET 2.0 Beta 1 released on 2/11/2008 includes the following new features, changes, and bug fixes:

  • New feature - LINQ to JSON!
  • New feature - Ability to specify how JsonSerializer handles null values when serializing/deserializing.
  • New feature - Ability to specify how JsonSerializer handles missing values when deserializing.
  • Change - Improved support for reading and writing JavaScript constructors.
  • Change - A new JsonWriter can now write additional tokens without erroring.
  • Bug fix - JsonSerializer handles deserializing dictionaries where the key isn't a string.
  • Bug fix - JsonReader now correctly parses hex character codes.

Added: 2/13/2008

Bill Horst Struggles to Emulate a FULL OUTER JOIN with LINQ to SQL

Bill's Converting SQL to LINQ, Part 9: Full Outer Join post of February 12, 2008 demonstrates creating the equivalent of a T-SQL FULL OUTER JOIN command with one initial LINQ query and two concatenated subqueries.

Apparently, this is the last of Bill's posts unless users suggest a different topic.

Links to all nine topics are available here.

Added: 2/12/2008

Alex James Reaches Part 4 of His Bulk Updates with Entity Framework Saga

If you want to avoid bringing a large number business objects into memory for bulk updating, Alex has the solution. In his Rolling your own SQL Update on top of the Entity Framework - Part 4 post of February 12, 2008, he shows you how he builds the final UPDATE [Table] SET Column = value, .... WHERE Key IN (...) query from Part 3's GetQueryInfo() method.

What would be interesting is a comparison of the performance of Alex's approach with the out-of-the-box bring-the-objects-into-memory-make-changes-and-invoke-SaveChanges() approach.

Following are links to Alex's three previous parts:

Added: 2/12/2008

Kathleen Dollard Moves from XSLT to LINQ to XML Literals for Code Generation

dnrTV's Kathleen Dollard on Code Generation in .NET video of February 1, 2008 describes Kathleen's recent development efforts in moving from XSLT to LINQ to XML literals. You can see an example of a language specific LINQ to XML literal template starting at 15:30. Language-independent (C# and VB) template generation examples follow.

Despite the fact that Kathleen doesn't like Microsoft's SingleFileGenerator approach, she plans to move to .edmx files for templates because they enable mapping between tables and objects.

Beth's two earlier dnrTV videos about VB 9.0 and C# 3.0 are at:

Thanks to Beth Massi for the heads up.

Added: 2/12/2008

Brian Dawson Continues His Entity Framework Performance Series

In his Exploring the Performance of the ADO.NET Entity Framework – Part 2 post of February 11, 2008, Brian starts by describing caching of Entity SQL queries and its dramatic affect on query execution time: 179 ms. for the first vs. 15 ms. for subsequent executions. The same LINQ to Entities query executes in 202 ms. vs. 18 ms.

Brian then goes on to describe the benefit of compiling LINQ queries, which increases the initial execution time to 305 ms. and reduces subsequent execution times to 15 ms. (Brian says "It’s true that in this case subsequent executions of the compiled LINQ query are slower than those of the non-compiled LINQ query," however, the data indicates otherwise.

Changing the MergeOption to no tracking has a dramatic affect on subsequent executions of compiled queries: 3 ms. vs 15 to 17 ms.

Brian concludes:

  • Initial creation of the ObjectContext includes the cost of loading and validating the metadata.
  • Initial execution of any query includes the costs of building up a query cache to enable faster execution of subsequent queries.
  • Compiled LINQ queries are faster than Non-compiled LINQ queries.
  • Queries executed with a NoTracking merge option work well for streaming large data objects or when changes and relationships do not need to be tracked.

Added: 2/12/2008

Stefan Sedich Discovers Cause of Slow LINQ to SQL Performance with VB

Stefan's Different SQL between VB.NET and C# LINQ to SQL SOLVED!! post of February 12, 2008 describes the cause of VB's added (COALESCE(CASE ... )) clauses: VB treats database fields that allow nulls differently from C#. Note that Northwind tables allow nulls in foreign-key fields that would throw referential integrity exceptions if set to null.

See the "Dramatically Poorer Performance of VB Than C# LINQ to SQL Queries" topic of LINQ and Entity Framework Posts for 2/4/2008+.

Added: 2/12/2008

DinnerNow.NET Updated for VS 2008 RTM

The open-source DinnerNow.NET sample ASP.NET application has been updated to .NET 3.5 and VS 2008 RTM. According to the CodePlex release site, the following new .NET 3.5/VS 2008 features have been added:

  • LINQ to SQL
  • WF/WCF integration
  • IIS7 & Windows Activation Services (WAS) hosting for WCF services
  • WCF 3.5 Syndication Services
  • WCF on the .NET Compact Framework 3.5

The DinnerNow 2.5 release has also been tested for compatib[ility] with Windows Vista, Windows Vista SP1, and Windows Server 2008 RTM.

You can download the bits from DinnerNow.net on CodePlex.

The Visual Studio 2008 Training Kit uses DinnerNow.NET in several of its online Labs.

Thanks to Guy Burstein for the heads-up.

Jim Wooley Upgrades the Personal Web Starter Kit's Data Tier from ADO.NET to LINQ to SQL

The Personal Web Starter Kit (PWSK) is a sample ASP.NET application that lets users organize individual photo files into albums stored in an SQL Server Express database. You can download the original version here.

Jim's Personal Web Starter Kit LINQed up post of February 10, 2008 shows you how he refactored PhotoManager.vb to replace ADO.NET SqlClient stored procedure calls with LINQ to SQL's parameterized dynamic queries. You can read more about Jim's PSWK version and download the upgraded project at his LINQ enabled Personal Web Site Starter kit site in the MSDN Code Gallery.

Jim also provides a set of guidelines for migration from SqlClient to LINQ to SQL in his LINQ Migration hints of the same date.

Sunday, November 18, 2007

Link and Entity Framework Posts for 11/19/2007+

Note: This compendium is updated daily or more often, depending on availability of articles. Updated November 20, 21, 23, 24 and 25, 2007.

Keith Farmer Takes on N-Tier Patterns with LINQ to SQL

From the "How Did I Miss This" department? (I missed it because Keith has been a infrequent poster—five posts from March to October 2007.)

Keith's LINQ and 3-Tier Dogma post of November 6, 2007 encourages developers not to be "pattern bigots" (my terminology) when it comes to multi-tier LINQ to SQL implementations. He says, undoubtedly in response to Dinesh Kulkarni's that LINQ to SQL Has No "Out-of-the-Box Multi-Tier Story:

The 3-Tier Model is just a pattern. And, like all patterns, It is meant to serve our needs, not the other way around.

He then goes on to examine the issue of the purity of separation of the data and logic layers:

    • Contractual purity (there is a set of well-known interfaces between the tiers)
    • Binary purity (the types are completely separate in each tier, *and* there is a contract between each)

and explains the advantage of abandoning binary purity in favor of contractual purity. He concludes:

The encapsulation of the data context is the creation of the logical layer.

His follow-on Encapsulation and LINQ to SQL post of November 13, 2007 provides a concrete implementation of encapsulating an IQueryable with a TableView class and an abstract class for wrapping a DataContext with a DataContextWrapper class. The article concludes with a sample implementation of DataContextWrapper.

Added: 11/25/2007

Bill McCarthy Excises LINQ to XML's Duplicate Namespace Declarations

Bill's Cleaning up your XML literal namespaces post of November 24, 2007 includes the code for a short utility program that removes redundant xmlns declarations from elements other than the root when you use the Element1.Add(Element2) method.

Added: 11/24/2007

CoDe Magazine Focuses on Data Access with LINQ and the Entity Framewok

The Data Programmability CoDe Magazine Focus Issue of December 2007 includes the following articles focusing on LINQ:

and these devoted to the Entity Framework:

All authors are from Microsoft's Data Programmability group.

Other articles cover SQL Server Compact Edition (SSCE) 3.5 and the new Sync Framework.

Added: 11/24/2007

LINQ to MPI.NET in Development at Phoster Incorporated

Adam Sobieski, a Phoster Incorporated developer, currently is completing development of System.Collection and System.Collection.Generic implementations for MPI.NET, which is a high-performance message-passing interface for .NET. According to his Update: LINQ to MPI.NET post of November 24, 2007, Adam plans to write a LINQ implementation for the collections.

Here's the University of Indiana's description of MPI.NET:

MPI.NET is a high-performance, easy-to-use implementation of the Message Passing Interface (MPI) for Microsoft's .NET environment. MPI is the de facto standard for writing parallel programs running on a distributed memory system, such as a compute cluster, and is widely implemented. Most MPI implementations provide support for writing MPI programs in C, C++, and Fortran. MPI.NET provides support for all of the .NET languages (especially C#), and includes significant extensions (such as automatic serialization of objects) that make it far easier to build parallel programs that run on clusters.

Adam's interest in LINQ to MIT.NET stems from his work on distributed AI applications using C# 3.0 and .NET 3.5. According to Adam's RETE, CEP, ESP post of the same day:

There are two types of machine reasoning popular today: CEP/ESP and RETE. There’s also combinations (Bruno Berstel, Alexandre Alves). I’m thinking P2P distributed applications with RETE/ESP using LINQ programming practices will allow for rapid-prototyping of some sophisticated AI applications. I’m presently brainstorming some developer libraries in this area (Semantic Grid, Knowledge Grid).

It's not yet clear to me how LINQ to MPI.NET would fit in with the ParallelFX program and PLINQ. PLINQ is directed to multi-core processors. My PLINQ Gathers Momentum post of December 8, 2006 (last updated 7/30/2007) includes many links to early PLINQ articles.

Added: 11/24/2007

Frans Bouma Reaches the Ninth Wave of LINQ to LLBLGen Pro Development

LINQ to LLBLGen Pro is coming along nicely using the LLBLGen Pro API to emulate LINQ to SQL but with the API's database-agnostic SQL intermediate language (IL). Frans is dropping the Skip() and Take() methods in favor of the API's pageNumber and pageSize values for paging, bypassing CROSS APPLY for SelectMany(), and implementing GroupJoin() and DefaultIfEmpty().

Frans' Developing Linq to LLBLGen Pro, part 9 post of November 23, 2007 provides the details of the trade-offs in implementing the preceding Standard Query Operators (SQOs) with the LLBLGen Pro API for multiple RDBMSs.

Note: The "Ninth Wave" refers obliquely to Eugene Burdick's prize-winning 1963 novel, which uses the Celtic ninth wave as a metaphor and Northern California as a backdrop.

Added: 11/23/2007

Bart De Smet Releases RTM Version of LINQ to SQOs

Back in the early days of the LINQ CTPs for VS 2005, Bart De Smet created a custom implemention of the LINQ Standard Query Operators (SQOs). His LINQSQO goes RTM post of November 22, 2007 announces that the RTM version of LINQ to SQOs is available on CodePlex.

The source code contains 148 unit tests that you can run with Visual Studio 2008 Pro or higher. This screen capture shows VS 2008 Pro's Test Results window displaying a few unit test results on the Query class library:

Added: 11/23/2007

Regenerating Original Entities from Entity Framework's ObjectStateManager

Neither the Entity Framework's ObjectContext or LINQ to SQL's DataContext is serializable, so you can't access the ObjectContext.ObjectStateManger's or the DataContext.Table<T>'s original values for an entity.

Danny Simmons' Creating an original value object from the separate values stored in the ObjectStateManager post of November 21, 2007 shows you how to create an an entity with all original property values populated from the partial (changed-value(s) only) data in the ObjectStateManager. Presumably, this entity would be serializable for cross-process transport.

Note: Don't confuse the term "value object" in Danny's post time with "complex objects" (a.k.a. Martin Fowler value objects.)

This post relates to Danny's earlier post about serialization depth (see below.)

Added: 11/23/2007

Alex James Joins the ADO.NET Team as Program Manager for Metadata

Alex James has moved from New Zealand to Seattle to join the ADO.NET Team as Program Manager for Entity Framework (EF) metadata. His initial Introductions blog post appeared on November 9, 2007 but the other ADO.NET EF folks didn't post an announcement, so I missed it. (Thanks to Julie Lerman for the heads-up).

Alex added the following EF-related posts after November 9:

Alex's posting frequency bodes well for his participation in the EF community.

Added: 11/23/2007

Danny Simmons on Serializing Entity Framework Object Graphs

Serializing Entity Framework (EF) object graphs to enable multi-tier data access scenarios incurs the same problems that caused Dinesh Kulkarni to admit that LINQ to SQL Has No "Out-of-the-Box Multi-Tier Story, as discussed in my post of October 18, 2007.

By default, the current EF CTP2 doesn't serialize associated entities. This omission requires that the client to make a method call for each set of instances required and then reconstruct the relationships locally. In this January 27, 2007 Entity Web Service: Returning Category thread Danny recommends creating a facade object to contain associated objects. The thread starter uploaded the alpha 0.1 version of a facade implementation to CodePlex.

Binary serialization for EF entities preserves associated entities but is limited to remoting or services on intranets because the payload won't pass through Internet firewalls. Binary serialization creates a deep clone of associated objects; that is, references to shared objects turn into individual copies of these objects. This results in what's called a "data explosion" and very large service/remoting payloads.

Danny's Question: Deep serialization of an object graph--how deep should it go? post of November 20, 2007 discusses three potential serialization options for future CTPs or versions:

  1. Return the entire object graph with 1:many and many:1 associations intact. Such graphs generate extremely large payloads and won't serialize with the default DataContractSerializer of Window Communication Foundation (WCF) because of cyclic references (also called cycles.)
  2. Remove the 1:many associations to prevent conflicts when multiple operations return graphs that include duplicate objects. LINQ to SQL implements this option by not serializing any 1:many associations. This is required to prevent cyclic references.
  3. Specify subgraphs on a method-by-method basis.

To serialize complete graphs with 1:many and many:1 (bidirectional) associations intact requires a rather complex workaround for the Windows Communication Framework's default DataContractSerializer or use of the NetDataContractSerializer.

Note that neither ObjectContext nor DataContext objects are serializable, which limits their identity managers and change trackers to in-process use.

Unless the ADO.NET team chooses one of the three options for EF v1, EF won't have an "out-of-the-box multi-tier story" either.

I'm working on a post with some examples and an analysis of a choice between options 2 and 3. Click here for a preview of the Serializing Object Graphs Without and With References post of November 21, 2007 (updated 11/23 and 11/25/2007) with downloadable files containing examples of serialized XML Infosets and schemas generated by the DataContractSerializer (DCS) and NetDataContractSerializer NDCS. Test with in-memory List<T> collections show that the NDCS serializes and deserializes bidirectional associations correctly.

Added: 11/20/2007 Updated: 11/23/2007 and 11/25/2007

Zlatko Michailov: Compiling LINQ to Entities Queries

Zlatko's previous post, Behavior of Variables in LINQ to Entities Queries of November 16, 2007, recommended compiling queries to remove LINQ to Entities' uncertain treatment of variables assigned literal values as constants or parameters.

Today's brief post, LINQ to Entities: Compiled Queries, explains the compilation process, which, like compiling LINQ to SQL queries, improves performance. Parameters are explicit for compiled queries.

Bill Horst of the VB Team: Converting SQL to LINQ Series

The VB Team posted the first of a series of articles, Converting SQL to LINQ, Part 1: The Basics (Bill Horst), on 11/19/2007. This episode covers basic LINQ query syntax. Future articles will cover LINQ equivalents to these T-SQL keywords:

  • FROM and SELECT
  • DISTINCT, WHERE, ORDER BY, Operators
  • Functions (Scalar and Aggregate)
  • GROUP BY and HAVING
  • Joins
  • UNION, TOP and Subqueries

InterLINQ Provider Alpha 0.2 Serializes Expression Trees

Pascal Schaefer and Manuel Bauer of the Swiss Software Solution Center have posted the Alpha 0.2 release of the InterLINQ library, including sample implementations for NHibernate, LINQ to SQL and LINQ to Objects, and a help file.

InterLINQ serializes the expression tree of a LINQ query so you can transport it across machine boundaries and execute it with a LINQ implementation on a server. It's up to you how to return the query result set to the client. LINQ to SQL lets you mark its partial classes as unidirectionally serializable, so classes with m:1 EntityRefs and 1:n EntitySets lose their EntityRefs because of the circular reference.

Tip: Right-click the InterLinq.chm file, choose properties, and click the Unblock button to read the help pages.

Danny Simmons: Entity Framework Beta 3 Due in a Few Weeks

From an answer to a question by Henrik Dahl in the ADO.NET (Pre-release) forum:

We're working hard to wrap up the last round of testing and bug fixes on the EF and the EF designer.  The plan is to release beta 3 of the EF/CTP 2 of the designer in a few weeks (think "early December").

Thanks to Julie Lerman for the heads-up.

Paul Stovell Explains SyncLINQ for Real and Derived Client State

In his Why SyncLINQ should matter to you post of November 15, 2007 and follow up Three categories of SyncLINQ queries article of November 16, Paul explains how derived state differs from real state in desktop client apps. He als demonstrates how SyncLINQ keeps derived state synchronized with real state as the data underlying real state changes.

Paul's in the process of coding the first SyncLINQ iteration. He writes:

In terms of right now, I have just implemented the first set of aggregate extensions, and I have a basic dependency system working. Over the coming week I’ll be working to implement an operator, and refactor much of the dependency system to support the overloads above.

His Introducing SyncLINQ post of October 16, 2007 includes a seven-minute video clip of SyncLINQ in action.

Note: There's still no library to download.

Mary Jo Foley: VS 2008 Rumored to be Available Monday 11/19/2007

Mary Jo writes "Sources say Microsoft will announce availability on Monday, November 19" in her "Visual Studio 2008 to go gold as soon as Monday" column of November 18, 2007.

eWeek's Daryl K. Taft quotes the MSDN Subscriptions WebLog post of November 16, 2007 in his Visual Studio 2008 Is Imminent post of November 17, 2007 as stating "Visual Studio 2008 is anticipated out early next week, with availability for subscribers." However, on November 18, 2007, the posts first sentence read "Visual Studio 2008 is anticipated out very soon, with availability for Subscribers." I assume the blog author edited the post without revision marks.

Be sure to review Dinesh Kulkarni's two LINQ Project General Forum posts about Beta 2 to RTM changes fo LINQ to SQL:

Jim Wooley suggests:

  • Open the DBML file as XML and change the UTF encoding from 16 to 8. Otherwise the compiler will complain about the DBML file's format.

Update 11/19/2007 1530 PST: LINQ to SQL Beta 2 to RTM Breaking Changes has been published as a downloadable .docx file. Charlie Calvert's Visual Studio 2008 Available for Download post has links to independently published files, such as the C# LINQ and language samples for Visual Studio 2008, which were updated 11/9/2007. The Visual Studio 2008 Samples page has a current list of samples for VB and C#.

Hopefully, the LINQ to Objects, LINQ to XML and LINQ to DataSets teams will post Beta 2 to RTM changes, if any, soon.

Update 11/19/2007 0700 PST: The rumors were correct. Microsoft made the download available but the MSDN servers were throwing  "Server Error in '/' Application. The file '/home.aspx' has not been pre-compiled, and cannot be requested." errors from the entry page for the download: https://msdn.one.microsoft.com/home.aspx?ApplicationID ..., which is not a good sign. Subsequently, the error messages changed to the more common "Server too busy."

Update 11/19/2007 0900 PST: Servers finally became operable.

Update 11/19/2007 1200 PST: Scott Guthrie has posted Visual Studio 2008 and .NET 3.5 Released with a summary of new features and links to related resources. Guy Burstein notes that you can download the Visual Studio 2008 and .NET Framework 3.5 Training Kit, too (120MB.)

Dinesh Kulkarni Writes a Common Base Class for LINQ to SQL Queries

If you want to "encapsulate a pattern and common behavior" across multiple business entities generated by SqlMetal.exe or the O/R Designer, Dinesh's "LINQ to SQL Tips 2: how to use common base class for all entities post of November 9, 2007 (released November 18, 2007) shows you how.

Danny Simmons: Handling Conditional Relationships in the Entity Framework

If your DBA has set up Relationships from Hell as described in Danny's An Interesting Relationship Mapping Scenario post of November 17, 2007 there might be a solution that works with Entity Framework v1, but it's more likely that you'll need to model a containment relationship with v2 (or later).

The many:one relationships Danny describes are defined by foreign key and type column values. The foreign key value points to the primary key of a table that's selected from a group of tables by a value in a type column. Only one many:one relationship occurs at any instance.

Danny describes a containment relationship thusly:

The basic idea of this construct is that "child" entities may be related to one or more "parent" entities but only one parent at a time.

The relationship Danny describes doesn't fit with my understanding of a containment relationship, which is more in tune with that described in the Object Containment topic of class notes for a Database Systems and Structures class at Simon Fraser University.