Tuesday, April 29, 2008

LINQ and Entity Framework Posts for 4/28/2008+

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

Matt Davey: Investment Banking Needs PLINQ

In his Parallel Extensions to the .NET Framework article of April 23, 2008 for Dr. Dobbs Portal, financial services developer Matt Davey discusses Microsoft Research's Dryad Network and DryadLINQ and suggests using a C# 3.0 extension method to use PLINQ to submit work to a DigiPede Distributed Computing Network. Matt concludes:

Sitting in the financial vertical, PLINQ can't be released quickly enough. As long as banks understand the implications, PLINQ will improve the trading cycle. Microsoft, however, needs to continue to push in the concurrency field, making developers' lives easier by giving them access to cores locally as well as remotely, and ensuring that the development/debugger tools keep up with the library as it advances.

Added: 4/29/2008

Julie Lerman Creates an Extension Method to Visualize EntityStateObjects

Julie's An extension method for visualizing EntityStateObjects post of April 29, 2008 shows the design and provides the source code to simulate a debugger visualizer for the current EntityStateObject. The EntityStateObject isn't serializable, so she wrote an extension method with the DEBUG ContitionalAttribute to prevent it from appearing at runtime.

Bravo, Julie! And thanks for the source code.

Added: 4/29/2008

Rob Conery Implements a Repository+ Pattern by Passing Out an IQueryable<T>

Rob starts a controversy by redefining the Repository pattern to a Repository+, which outputs IQueryable<T>. With help from Oren Eini (Ayende Rahien), Rob adds a LazyList<IQueryable<T>> to provide lazy-loading generic list without relying on LINQ to SQL's built-in lazy loading feature.

He then goes on to discuss with John Galloway the use of HTML and CSS in ASP.NET MVC to create a UI for the project replacing tables with divs for layout.

Added: 4/29/2008

Randolph Cabral Continues His LINQ to SQL n-Tier Series

Exploring N-Tier Architecture with LINQ to SQL (Part 2 of n) of April 29, 2008 proposes wrapping a LINQ to SQL NorthwindDataContext object with a NorthwindBusinessContext to decouple the DataContext from the business layer and adds GetCustomerById() and PersistState() methods to more closely resemble the ActiveRecord pattern.

Added: 4/29/2008

Google Engineer Admits the App Engine Has Latency Problems Reading and Writing Datastore Entities

Perhaps apps running on the Google App Engine aren't as scalable as one might assume. According to Ken Ashcroft, a Google software engineer, who wrote Tips on Writing Scalable Apps of April 29, 2008:

    • Avoid contention on datastore entities. If every request to your app reads or writes a particular entity, latency will increase as your traffic goes up because reads and writes on a given entity are sequential. One example construct you should avoid at all costs is the gobal counter, i.e. an entity that keeps track of a count and is updated or read on every request. There are some interesting ways of simulating this behavior that don't require reads/writes on every request, and we'll talk about a handy way to cache entities for reads below.
    • Avoid large entity groups. Any two entities that share a common ancestor belong to the same entity groups. All writes to an entity group are sequential, so large entity groups can bog down popular apps quickly if there are a lot of writes to that group. Instead, use small, localized groups in your design.
    • Write sparingly. Writes are more expensive than reads; keep this in mind when designing your data model. If you can avoid a write--it's best to do so.

Added: 4/29/2008

Charlie Calvert Seeds the LINQFarm with an IEnumerable<T> Series

C# community evangelist Charlie Calvert starts another multipart LINQFarm series with LINQFarm: Understanding IEnumerable<T>, Part I, which (as you'd expect) covers the IEnumerable<T> interface.

The second member of the series promises to answer "What is it about IEnumerable<T> that makes it a useful data source and return type for LINQ to Objects queries?"

Added: 4/29/2008

Phil Wainewright Translates Steve Gillmor's Live Mesh Accolade

Phil's Gillmor: Why Google should worry about Live Mesh post of April 28, 2008 summarizes Steve's sometimes rambling 1,000+ words from his surprisingly effusive TechCrunch article, Microsoft Says Yes With Mesh of April 27:

Other commentators have dismissed Mesh as simply a mechanism to protect Microsoft’s desktop-bound assets, but Steve turns that around and points out that what Mesh is really about is connecting the desktop into the cloud (Meshing the desktop into the cloud, as I wrote last Thursday).

Call it self-serving if you like, but Microsoft needs a bridge that will carry its existing market presence over into the cloud and Mesh is that bridge. You could equally call it customer-friendly: Microsoft users will likely be pleased to have a mechanism that helps them make that transition without orphaning their desktop and on-premise IT assets.

Robert Scoble has a shorter translation in Mind Meshing with Steve Gillmor of April 27, 2008:

The only good excuse I’ve heard so far why Microsoft Mesh isn’t interesting is “I hate Microsoft.”

That’s a tough thing to overcome, but I thought Steve Gillmor was one of those who hated Microsoft too. After all, he bought a Mac and kept repeating on his blog “Office is dead.”

But, let’s translate Gillmor: Microsoft Mesh is fascinating. Agreed.

Steve didn't sound all that enthusiastic about Live Mesh during the Gillmor Gang's interview podcast with Dave Treadwell that I reported in the "Sync Guru (Rafik Robeal) Questions the Problems Live Mesh Will Solve" section of LINQ and Entity Framework Posts for 4/21/2008+.

Note: If you're wondering why Live Mesh is germane to the usual topics of this blog, it's because it includes a LINQ implementation ("LINQ to Mesh") and of the potential interaction of Live Mesh with ADO.NET Data Services and SQL Server Data Services (SSDS) as a primary data sources. (Updated 4/29/2008)

Update 4/29/2008: Ori Amiga attempts (but fails) to execute a LINQ to Mesh query against Mesh objects at 47:25 into the Ori Amiga: Programming the Mesh Channel 9 video segment of April 24, 2008. Starting at about 50:00, he shows the code for a typical LINQ query and mentions that the Mesh team is working with the Astoria folks to make sure their query and URL syntaxes are the same.

Other Channel9 videos about Live Mesh:

Bart DeSmet Follows Up on His TechDays Sessions on IQueryable

His Q: Is IQueryable the Right Choice for Me? post shows you how to:

[C]reate your own query pattern implementation by means of instance methods ... by providing an entry-point like Table<T> and further providing a fluent interface pattern that produces Query<T> objects in a chained manner.

as an alternative to implementing IQueryable<T>.

It's nice to see Bart returning to posts about LINQ.

Dinesh Kulkarni Has Resumed Posting about LINQ to SQL

After more than six months of silence following his move "I have moved to another project with the developer division at Microsoft (more about that on a sunny day)" reported in his LINQ to SQL: What is NOT in RTM (V1) post of October 15, 2007, Dinesh posted Lifetime of a LINQ to SQL DataContext on April 27, 2008.

Apparently the sun hasn't shone in Redmond since mid-October.

His latest post provides guidelines for answering the question of whether the DataContext should be short- or long-lived.

As I said in my comment: Welcome back!

Eugenio Pace Produces Screencast of LitwareHR Using SSDS

End to end demo of LitwareHR on SSDS provides an 11-minute screencast of LitwareHD using SQL Server Data Services instead of SQL Server 2005 as the back-end datastore. Eugenio divides the screencast into two acts:

    1. Tenant Provisioning and customization (takes the first 5 min approximately). I show the initial tenant provisioning (creation of a new tenant in LitwareHR, initial configuration, etc) and then a basic customization (e.g. look & feel, position entity shape, etc). You'll notice that I switch back and forth between www.litware.com and SSDS to show how entities look like in the store.
    2. Using the new created instance (this takes the last 6 min). I show a hypothetical recruiter logging-in, opening new positions, then an applicant browsing the open positions and submitting a Resume and finally the recruiter browsing the posted applications. Again, you'll see how do these entities look like in SSDS.

Here are Eugenio's introduction and six-part tutorial about moving LitwareHR to SSDS:

Barry Gervin Starts Yet Another Entity Framework Series

His kickoff, The Entity Framework vs. The Data Access Layer (Part 0: Introduction) of April 27, 2008, explores the roles of a data access layer (DAL, not necessarily a tier) and lays out questions related to it's implementation.

Barry promises that in Part I:

I'll explore the idea of the Entity Framework replacing my data access layer and evaluate how this choice rates against the various objectives above. I'll then continue to explore alternative implementations for a DAL using the Entity Framework.

Liam Cavanagh Offers Sync Framework Tutorials

In apparent response to the increased interest in data synchronization spiked by Live Mesh, Liam's New Sync Framework Tutorial of April 28, 2008 offers the following four projects:

  • Sync101 With Metadata Store – Demonstrates a basic provider for an in-memory data store (replica) that uses the SqlCeMetadataStore class to store the metadata in a SQL Server Compact Edition database.

  • Sync101 Refactored – Factors out the replica-specific code from the code common to any provider in preparation for the next step of adding an additional provider. Also uses a more flexible transfer mechanism class to allow accommodation of more complex schemas.

  • Sync101 Add Xml Provider – Adds a new provider that represents a data store comprised of XML files.

  • Sync101 Add Csv Provider – Adds a new provider that represents a data store containing Comma-Separated Values (CSV) files and also uses XML configuration files to specify the transfer mechanism class properties and the property mappings between providers.

You can download the source code from the MSDN CodeGallery.

Julie Lerman Unveils the Forthcoming ASP.NET EntityDataSource Control

Repeated from: LINQ and Entity Framework Posts for 4/21/2008+

Danny Simmons demonstrated the EntityDataSource control at the MVP Summit 2008 and Julie shares her notes in Sneak Peek at the EntityDataSource Control of April 27, 2008. The EntityDataSource control is the Entity Framework's answer to LINQ to SQL's LinqDataSource control for databinding ASP.NET GridView, ListView and other bindable server controls.

Two important EntityDataSource control features that Julie describes are:

Although I don't remember seeing it during the session, Danny did say that you can choose to eager load related data in the same way that you can with the Include method. I don't know how this is done or if it will impact updating, but I don't know why it would.

One of the most interesting things about the EntityDataSource is that along with its' ability to perform server side paging, it also performs client side caching - of current AND original data. The original data is not stored as complete objects, but the minimal data necessary to reconstruct state when it's time to update. Updates happen, like any other data source, one at a time. So you have to pick an item, edit it and update it.

Availability of the EntityDataSource control will enable ASP.NET Dynamic Data scaffolding to use EF as an alternative to LINQ to SQL as its data source. (See David Ebbo's Dynamic Data at MIX, and upcoming changes post of March 6, 2008.

Hopefully, the EntityDataControl won't share the problems with the LinqDataControl that Julie described in her January 22, 2008 Thinking about the EntityDataSource post.

Note: The link to the OakLeaf blog in the latter post goes to the home page. Julie might have intended to link to go to the Problems Using Stored Procedures for LINQ to SQL Data Retrieval (Updated) post of October 2, 2007. That post contains a "Problems with Stored Procedures That Affect ASP.NET Projects Only" section, which covers sorting and paging problems.

0 comments: