Monday, February 16, 2009

LINQ and Entity Framework Posts for 2/5/2009+

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

Entity Framework and Entity Data Model (EF/EDM)

Danny Simmons explains in his D3: Basic Architecture Decisions post of 2/15/2009 the basic goals of his forthcoming DPMud3 Data Programmability multi-user dungeon game. Danny writes:

The first goal for this exercise is to build a real application not just a collection of samples artificially glued together but at the same time to try out new EF features such as POCO, model-first, mockable-interfaces, the n-tier APIs, T4 for code generation, etc. Another key goal is to use good architectural principles and popular app building patterns which means carefully separating concerns, using Inversion of Control to facilitate mocking and test driven (or at least very carefully tested) development, to create an n-tier architecture with WCF-services and a Silverlight client, and to use a model-view-controller pattern to simplify the creation of multiple views and controllers which share a common model.

Danny’s DPMud post of 2/13/2009 recounts the history of the original multi-user dungeon game that he used as a test harness for Entity Framework v.1 and describes the start of “DPMud3: The Zombies Search for Spock,” v.3 of the game for EF v.2. Danny promises to share the source code as soon as he finishes “working out some details with legal.”

Wriju recommends using EntityClient and eSQL to improve performance in his ADO.NET Entity Framework: Using EntityClient and EntitySQL post of 2/12/2009 and shows you how to handle paging in ADO.NET Entity Framework : Paging EntitySQL of 2/13/2009.

Simon Segal tries to get Specifications, Repositories and (finally) Fetching Strategies bundled into a single approach for the Entity Framework in his The Entity Framework and a unified Lazy and Eager loading framework. post of 2/11/2009. Simon concludes:

So far the results look promising. I will have more to say on this shortly and with a bit of luck will be releasing the code which rounds out the triad of a Repository, dynamic querying capability via Specifications and Fetching Strategies for a unified approach for lazy and eager loading that does NOT require you ever explicitly call the .Includes(), Load() or IsLoaded methods and property on the EntityCollection<T>, EntityReference<T> or ObjectQuery<T> objects.

Muhammad Mosa’s Domain Driven Design & Test Driven Development\Design with Entity Framework, Part 1.a Refactoring & Unit Testing post of 2/11/2009 has the following objective:

My target is to achieve decoupling between EF and all layers above it. This include Repository classes. This might not be of a big benefit to everyone, because my repositories implementation will still dependent on IDataContext. But for me it will help to do TDD more smoothly regardless of my underlying data access layer. Beside it might allow me in future to be able to switch from EF to LINQ to SQL and just implement my IDataContext interface for LINQ to SQL.

Downloadable source code for EF is included.

Julie Lerman announces Amazon is finally listing my book as "in stock" on 2/10/2009.

Grigori Melnik’s Thoughts on Agile Software Engineering and Beyond post of 2/9/2009 asks “DAAB and Entity Framework: possible marriage?” Grigori answers:

We’ve looked at this a little bit internally and we do not see any opportunity or value in this marriage. We might be missing something here. For those, who had asked for this, could you please provide more details about how this integration would work and what values you’d derive from it?

Danny SimmonsAvoiding Query Injection Attacks with the EF post of 2/8/2009 explains how to use ObjectQuery<T>’s builder methods to add filters, sorting and projections to EF queries. The builder fully parameterizes the queries.

See Kristofer Andersson’s Tools - Part 10 - Add-ins - Multiple diagram layouts per model in the Linq-to-SQL designer post of 2/11/2009 below.


See Nathan Duchene’s Storing Values in XML & Using Linq to XML in VB to retrieve them post in the LINQ to Objects, LINQ to XML, et al. section.

David Hayden’s LINQ To SQL Tutorials - Lazy-Loading Properties for Performance post of 2/12/2009 shows you how to take advantage of the DelayLoading property to defer loading of large binary objects, such as images, to improve performance.

See Muhammad Mosa’s Domain Driven Design & Test Driven Development\Design with Entity Framework, Part 1.a Refactoring & Unit Testing post of 2/11/2009 in the Entity Framework and Entity Data Model (EF/EDM) for possible use of his interfaces with LINQ to SQL.

Kristofer Andersson’s Tools - Part 10 - Add-ins - Multiple diagram layouts per model in the Linq-to-SQL designer post of 2/11/2009 describes a new feature for LINQ to SQL mapping with his Huagati DBML/EDMX Tools: Layout View. Layout View enables developers to “‘chunk up’ models in digestable pieces; sometimes referred to as subject areas or functional areas.” Kris notes:

All data modelling tools support this, Visio 2003EA, Erwin, ERStudio, even the ‘diagrams’ feature in SQL Enterprise Manager all allow each model to have multiple diagram layouts/views. …

Unfortunately this feature is missing in both the Linq-to-SQL diagram designer and the Entity Framework designer in Visual Studio 2008. Also unfortunate is that the people responsible for those designers in Microsoft’s data programmability group don’t seem to prioritize that ability. Microsoft’s Sanjay Nagamangalam recently wrote “While we understand your scenario, it does not look like the next version of the designer will support viewing subsets of the EDMX at the moment.” in the comments section of the EFDesign blog as a response when a user asked for the ability to view subsets of a model in the EF designer.

Huagati offers a 30-day free trial of the v.1.62 beta version for LINQ to SQL. A decision is pending on extending this feature to the Entity Framework v.1 and will be influenced by user interest demonstrated during the beta.

Shefali Kulkarni takes on Single Table Inheritance using LINQ [to SQL] on 2/11/2009 and describes mapping a single table to a class hierarchy with LINQ to SQL.

Keven Kubasik’s Using Linq to Sqlite Providers: Updated post of 2/9/2009 provides step-by-step instructions for using the EF-enabled Sqlite provider.

Matthieu Mezil writes in his EDM Designer V0.9 post of 2/9/2009 that My first EDM Designer version was a viewer. It's now a real designer. Check it out.

Matthieu Mezil shows you how to Integrate cache in the query with the IntegrateContext(context, where.Compile()) method (2/6/2009) in a LINQ to Entities query.

LINQ to Objects, LINQ to XML, et al.

Nathan Duchene’s Storing Values in XML & Using Linq to XML in VB to retrieve them post of 2/13/2009 describes a project on which he was working:

Take uploaded XML files, do some file validation against a database using LINQ to SQL, and distribute these files across our network based on the values within the XML file.  Through all this, wire in notifications if the file fails a validation test.

The VB LINQ to XML implementation described in Nate’s post shows you how he accomplished the feat.

Bart De Smet hollers Help! Drowning in Expression Trees, What Now? on 2/12/2009 when attempting complex expressions that contain user-defined functions in LINQ to Objects predicates.

Suprotim Agarwal shows you how to Group By Multiple Values in LINQ in his post of 2/12/2009.

Matthieu Mezil wants to write an extension method Sum on IEnumerable<int> and an extension method Sum on IEnumerable<decimal> and then factorize this code in his Code factorization with delegate post of 2/11/2009. Matthieu asks “how to factorize the initialization (= 0 with an int and = 0 with a decimal) and the addition?” and then shows you the code.

LinqMaster’s 7 LINQ Tricks to Simplify Your Programs post of 2/9/2009 shows you how to:

    1. Initialize an array
    2. Iterate over multiple arrays in a single loop
    3. Generate a random sequence
    4. Generate a string
    5. Convert sequences or collections
    6. Convert a value to a sequence of length 1
    7. Iterate over all subsets of a sequence

Kai Jaeger’s JSINQ - LINQ to Objects for JavaScript CodePlex project of 2/1/2009 is a JavaScript library that allows you to write SQL-like queries against arrays and DOM node lists. According to Kai:

JSINQ is a complete implementation of LINQ to Objects in JavaScript. What that means is that if you know LINQ and you know JavaScript, you know JSINQ. JSINQ is both an API-compatible implementation of System.Linq.Enumerable and a complete query-expression compiler. That's right: you can write LINQ-style queries in JavaScript. And if that isn't enough: JSINQ is also very liberally licensed, well-document, reasonably well-tested (the Enumerable-part) and currently in beta. So give it a go!

Bart de Smet takes up matrix methods in his LINQ and The Matrix – Introducing MLinq post of 10/11/2009. MLinq provides “a very simple way to perform symbolic matrix calculations based on LINQ expression trees.” For consistency, I prefer the name “LINQ to Matrices”

Fabrice Marguerie’s Converting LINQ queries from query syntax to method/operator syntax post of 2/6/2009 describes how to “convert a LINQ query expression (query syntax) to a query operator call chain (method syntax or dot notation).” The solution definitely wasn’t intuitive.

ADO.NET Data Services (Astoria)

Steve Naughton’s back with an AJAX History in a Dynamic Data Website post of 2/13/2009 that explains how to improve users’ experience when navigating history with several filters on each list page.

Rob Bagby explains working with AtomPub in Exposing ATOM feeds from your services – part II – customizing and extending the ATOM feed of 2/13/2008 and the importance of RESTful interfaces in Exposing ATOM feeds from your services of 2/12/2009. Astoria and Azure services implement RESTful interfaces.

Shawn Wildermuth’s Twin Cities Developers' Guild Code Sample of 2/13/2009 includes the source code for a data application using Silverlight and ADO.NET Data Services to show how Line of Business apps can work in Silverlight.

Beth Massi is up to part 3 of her Astoria-powered Office Business Application series in OBA Part 3 - Storing and Reading Data in Word Documents of 2/12/2009. Earlier episodes are

Steven RobbinsSelf Hosting ADO.Net Data Services (Astoria) – Part II – A Basic WCF Service Example follows up his original article with a very basic introduction to WCF services in general using Astoria as the example. Source code is available for download.

ASP.NET Dynamic Data (DD)

Jonathan Carter’s Dynamic Data: Putting A New Dress On An Old Model post of 2/12/2009 starts with this observation:

Within the .NET 3.5 SP1 release, the initial consumer of Dynamic Data (and the newly introduced data annotations) was ASP.NET WebForms. This means that if you’re developing a data-driven web application, and your weapon of choice is WebForms, then you just happen to be in luck. Work is already underway to introduce some of Dynamic Data’s behavior into ASP.NET MVC that is appropriate to its style of development, and you can expect to see additional UI frameworks taking advantage of its semantics and data annotations as well in the near future.

And then asks and answers: “How can I begin taking advantage of it within a WebForms application?”

SQL Data Services (SDS) and Cloud Computing

This topic moved on 1/3/2009 to Windows Azure and Cloud Computing Posts for MM/DD/YYYY+.

SQL Server Compact (SSCE) 3.5 and Sync Services

Liam Cavanaugh’s Customer Spotlight - Synchronization Scalability and Live Toolbar post of 2/11/2009 discusses the scalability of syncing Website Favorites across multiple PCs with the new version of the Live Toolbar and the Microsoft Sync Framework.

Liam’s Customer Spotlight – Interscape Flip for the Mobile Sales Workforce of 2/10/2009 introduces another company, Interscape, who has developed a simple to use sales tool called FLIP Client. Liam writes:

Flip was built to incorporate features like scheduling, pipeline reporting, outlook and more.  I had a chance to talk with Matt Francis, CEO of Interscape and this is what he had to say about the Sync Framework and Occasionally Connected Applications.

Mary Jo Foley’s In Apple’s footsteps: Google licenses Microsoft ActiveSync post of 2/9/2009 describes how:

Google apparently is licensing ActiveSync in order to allow tighter synchronization between Exchange and its  newly unveiled Google Sync service.

Miscellaneous (WPF, WCF, MVC, Silverlight, etc.)