Sunday, July 13, 2008

LINQ and Entity Framework Posts for 7/7/2008+

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

Comparison of Entity Framework and LINQ to SQL Projects Using a 120-Table Database

Kristofer Andersson of Huagati Systems, Bangkok, is in the process of developing an airline passenger reservation system (APRS) example and has posted a database diagram and T-SQL DDL script to create the 120 tables of its data model in his Data Model - Basics - Part 10 - Overview #2 and SQL-DDL script post of June 29, 2008.

I created the database in a local SQL Server 2005 Express instance and wrote simple LINQ to SQL and ADO.NET Entity Framework (EF) projects to compare the characteristics of the two data access layer approaches. Tests showed that it took 24 times longer to initialize the EF than the LINQ to SQL version (9.426 vs. 0.394 seconds).

Precompiling the view with a T4 template from the ADO.NET Team’s How to use a T4 template for View Generation post reduced the initialization time to 2.063 seconds, which is still about five times longer than LINQ to SQL. However, a substantial workaround is required to prevent an exception when running the EF project from its Release (or Debug) *.exe file. See my Comparison of Entity Framework and LINQ to SQL Projects Using a 120-Table Database post of July 12, 2008 for more details.

Added: 7/13/2008

Charlie Calvert Continues LINQ Farm Renaissance with More on Set Operators

Charlie’s LINQ Farm: More on Set Operators post of July 12, 2008 provides “simplified examples of how to use each of the operators:” Union, Intersect, Distinct, and Except. “[A]nd then ends with a more complex example that shows how the operators might be used in a real world setting.”

Added: 7/13/2008

Guy Burstein Delivers EntityDataSource Screencast from Microsoft’s Silverlight Streaming Site

Guy’s ‘EntityDataSource Screencast – Hosted on Silverlight Streaming post of July 12, 2008 demonstrates how to use the ASP.NET EntityDataSource. The associated How To: Host Your Screencasts on Silverlight Streaming post of the same date is an illustrated tutorial for taking advantage of Microsoft’s free Silverlight Streaming service.

Added: 7/13/2008

Mike Flasko Alex James Promotes ADO.NET Data Services’ Uniform Interface with Varying Data Source Schemas

Mike Alex says in Using the Uniform Interface Exposed By Data Services of July 11, 2008:

In some of our past posts, we've discussed one of the benefits of data services is that the interface to such a service is uniform.  This means that how you interact with each service (issue a query, insert a new entity, etc) is the same across all services regardless of the schema being exposed.  This uniform interface leads to one of the value propositions of data services, which is the ability to create reusable code for service consumption.  That is, one can now write reusable client libraries, LINQ providers, app/UI components, widgets, etc that are able to work across any data service.

Hopefully, the preceding will apply to the promised unified client library for SQL Server Data Services.

Added: 7/13/2008 Updated 7/21/2008: Attribution error

Use the ASP.NET Cache for LINQ to SQL Generic Lists

J Sawyer, a Microsoft developer evangelist in Houston demonstrates a Cool way to do ASP.NET Caching with Linq with C# and VB in his detailed post of July 11, 2008. I haven’t tried it, but the technique should apply equally to Lists created from Entity Framework’s ObjectContexts.

Added: 7/13/2008

Pablo Castro Responds with His Software Development Meme

Julie Lerman tagged me and I tagged Pablo. Here’s his Software Development Meme of July 10, 2008.

I notice Pablo included SQL in his list of programming languages he has used. Neither Julie nor I included SQL (which we both use constantly) in our lists. I’ve never thought of SQL as a programming language. I’ve always considered SQL as a set-based data manipulation language, although T-SQL stored procedures probably qualify it as a PL. What’s your take?

Added: 7/13/2008

Maíra Wenzel Starts ASP.NET Dynamic Data - Tips and Tricks Series

Maíra’s first episode, ASP.NET Dynamic Data - Tips and Tricks #1 of July 11, 2008, covers the dreaded The control 'DataSource1' does not have a TableName property and a table name could not be inferred from the URL exception.

Added: 7/13/2008

Samuel Jack Uses a Hydraulic Analogy for Reporting Progress of and Canceling LINQ Queries

His Reporting Progress During LINQ Queries of July 7, 2008 and Canceling Long-Running LINQ Queries of July 10 use “LINQ Pipeline Monitors,” which Sam analogizes as:

One way to think of LINQ queries with sequences is as a pipeline, or an oil refinery. You have the data source (often a collection) acting like the oil well, but producing items. Items flow along the pipeline (think of the "."s in the expression as the pipe). Some items are removed from the pipeline by filters - Where clauses; some items are converted to other products - Select clauses; finally, just as oil is cracked, and graded into gasoline and diesel etc. items in LINQ queries are often grouped and sorted. In oil pipelines there are also flow meters, measuring how much oil is going through the pipes. If we can create the equivalent of a flow-meter for LINQ queries, then we've got our means of reporting progress.

Having been in the petroleum flowmeter business for many years (in an earlier avatar), the analogy appealed to me.

Added: 7/13/2008

Tech*Ed 2008 IT Pro Session DAT251: Introduction to SQL Server Data Services (Video)

From the session’s description:

Cloud computing offers many benefits to business customers looking to increase operational efficiencies, lower operational costs and/or move to a Software as a Service (SaaS) model. This session provides an overview of Microsoft SQL Server Data Services (SSDS) and walks through on-boarding and typical usage scenarios to show how SSDS brings the power of scale-free storage, distributed computing, and reliable data processing to new and existing business solutions. Speaker: Soumitra Sengupta.

For more details and a link to the one-hour video segment: Tech*Ed 2008 IT Pro Session DAT251: Introduction to SQL Server Data Services (Video).

Alex James on Entity Framework v2 Design: Query Caching

Alex’s Transparent Caching Support in the Entity Framework post of July 9, 2008 lays out the design of a proposed query caching implementation. From the introduction:

Entity Framework can be extended to handle data caching in a transparent way, so that any application using it can take advantage of caching with little or no modification. In Entity Framework V1 it is possible to implement transparent caching using a custom provider as demonstrated in EFCachingProvider sample (TBD). We are considering adding caching as a first-class concept in Entity Framework V2 so that it will no longer be necessary to use a wrapper provider approach.

The design caches queries, not EntityObject instances, so the queries can be reused.

Steve Naughton Starts a ASP.NET Dynamic Data Series for Custom Pages

Steve concludes that there are three now four types of ASP.NET Dynamic Data custom pages:

  • Standard Custom Page based on an existing PageTemplate and customised in the DynamicData\CustomPages folder.
  • A completely Custom Page again in the DynamicData\CustomPages folder.
  • Standard ASP.Net Page with Dynamic Data features added to take advantage of the FieldTemplates.
  • Added 7/13/2008: A DetailsView and a GridView using Validation Groups

Following are posts with instructions and sample code for the first two four types:

I’ll update this post when Steve completes Part 3.

Updated: 7/13/2008

David Hayden Demonstrates LLBLGen Pro New LINQ to SQL Templates with an Update Model Feature

Entity Framework has an Update Model from Database feature but LINQ to SQL doesn’t (and probably never will.) Dave’s LLBLGen Pro LINQ To SQL Templates with Model Refresh from Database - O/R Mappers post of July 9, 2008 explains the benefit of the template’s “update model” feature:

The attraction to using something like the LLBLGen Pro Designer instead of the Visual Studio 2008 LINQ To SQL Designer with LINQ To SQL is that the LLBLGen Pro Designer will pick up changes to the database and update the model accordingly. For very few tables this is not a big deal, but as the number of tables grows and you have DBA's making changes to the database schema it is very easy to get your model out-of-sync with the database. With LLBLGen Pro you can just refresh the catalog and it will pick up those changes for you. With the LINQ To SQL Visual Designer in Visual Studio 2008 I don't know of a real easy way to find those changes and update your model.

And demonstrates how to use it.

Jonas Stawski: Use the Code-Generated Initialize() Method to Detach and Initialize Each Entity

Jonas is “working on an article on how to use LINQ to SQL in an N-Tier environment with ASP.NET (without WCF),” so he needs to detach and reinitialize each entity. His LINQ To SQL Generic Detach post of July 9, 2008 explains a simple approach to doing the job.

Jonas (an MVP) promises to post a notice when the article is published.

Sprint 3 for SQL Server Data Services Will Add Several New Features

An e-mail from the SQL Data Services (SSDS) team dated July 8, 2008 announces that Sprint 3 will add support for Blobs, timestamp versioning, ETag, HEAD, If-Match, Accept and a new content type when the latest update goes live.

Get more details in Sprint 3 for SQL Server Data Services Will Add Several New Features of July 9, 2008.

Matt Warren Surfaces with Part 10 of His LINQ: Building an IQueryable Provider Saga

After a six-month hiatus, Matt posted a very lengthy LINQ: Building an IQueryable Provider - Part X chapter on July 8, 2008. Topics covered are:

  • Grappling with GroupBy and Aggregates
  • The GroupBy Operator
  • Aggregate Binding
  • Aggregate Rewriting
  • Taking it for a Spin

As usual, a C# tour de force with downloadable source code.

Elisa Flasko’s “Achieve Flexible Data Modeling With The Entity Framework” Article in MSDN Magazine for July 2008

Elisa’s “Achieve Flexible Data Modeling With The Entity Framework” is an overview of the Entity Framework and Entity Data Model that will be distributed with Visual Studio 2008 SP1.

The blurb says “Here the author answers questions regarding the Entity Framework and provides an understanding of how and why it was developed” and the article covers:

    • The philosophy behind the Entity Framework
    • The Entity Data Model
    • Querying, mapping, and n-tier development

Eric White Posts Updated LINQ to XML Code for the Open XML SDK

Eric describes is Open XML SDK and LINQ to XML post of July 8, 2008 as follows:

In this post, I’m presenting some code that uses the Open XML SDK and LINQ to XML to query an Open XML document. I’ve posted on this before, but this version is cleaner and smaller. It also is an example of code written in the functional style.

The most common need is to retrieve the paragraphs of a word processing document. But I've also had the need to dig into a spreadsheet, and get the data out for a row, a set of rows, or all the cells in a column. You can think of the code presented here as a (very) small library on top of the Open XML SDK.

LINQ for PHP Clone Sighted

Mike Borozdin asks Is PHPLinq As Cool As Real LINQ? in his post of July 4, 2008. Unfortunately, Mike says the answer is “No” because PHPLinq’s query keywords aren’t part of the language. They’re strings.

Alternative Approaches to Cascading Deletions in LINQ to SQL

“Salyse” analyzes various approaches to implementing cascading deletions on the client or server side in his “Cascading Deletes in LINQ to SQL” article of July 7, 2008 for the Code Project.

Phani Raju Analyzes 1:1 Associations in ADO.NET Data Services

Phani’s Working with Associations in ADO.NET Data Services Beta 1 post of July 2, 2008 provides a detailed analysis of managing 1:1 associations in Astoria.

He promises that his next post will cover the more common 1:n associations.

(Phani is a new arrival on the Astoria team; his previous position was a Microsoft product support specialist (PSS). Thanks to the Astoria Team for the heads up on the blog.)

Live Demo of Custom Pager Implementation for LINQ to SQL

Muhammad M. Mosa Soliman’s Building Custom Paging with LINQ, ListView, DataPager and ObjectDataSource, Different Paging Method post of July 8, 2008 combines techniques from Justin Etheridge’s Efficient Paging in SQL Server 2005 and Kevin Hazzard’s Efficient Paging in SQL Server via LINQ post and provides source code and a live demo of his interpretation.

Steve Naughton Continues His Permutations and Combinations of the FileImage_Edit FieldTemplate

Steve’s Dynamic Data: Part 2 - FileImage_Edit FieldTemplate of July 7, 2008 implements these new ideas:

  1. Image Aspect Ratio lock, keeping the proportions of the image the same when resized.
  2. Doing the same as DynamicDataFutures disabling EnablePartialRendering when the FileImage is in an Edit or Insert page.

Microsoft’s Live Expo Classifieds Database Bites the Dust; Is Google Base Next?

Online classified advertising databases are having a tough time competing with ClickZ’s Craigslist Rivals Struggle to Succeed in Web Classified Space post of July 7. The article says Google Base “garnered about 743,000 unique visitors in May compared to Craigslist's 26.7 million, according to Nielsen Online.” I wrote about what became Live Expo and Google Base during their gestation period (see Windows Live "Fremont" vs. Google Base Classifieds) of November 29, 2005.)

Microsoft will terminate Live Expo on July 31, 2008.

Google shut down it’s Froogle shopping service in April 2007. The http://froogle.google.com now displays an anemic Google Product Search page. URL Perhaps Google should call it quits for Google Base, too.

David Robinson Cooks Concurrent Data Access and Concurrency in Batch Updates Best Practices Soup

Dave’s Best Practice - Take Advantage of Concurrency post of July 6, 2008 uses the term concurrency in an uncommon context: Concurrent CRUD operations against the same authority by multiple front ends. His summary:

  • Multithread your SSDS calls when appropriate
    • Use Asynchronous access patterns
    • Helps combat latency
    • Many front-end servers able to handle many requests
  • Things to watch out for
    • SSDS Supports Simple Concurrency Today
    • Multiple entity updates need to be managed by your application
    • No support for batching today, but its coming

0 comments: