Tuesday, May 27, 2008

LINQ and Entity Framework Posts for 5/22/2008+

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

SQL Server Data Services Rolls Out "Sprint 2" Upgrade

The SQL Server Data Services (SSDS) team's Sprint 2 goes live post of May 26, 2008 announces the second upgrade to SSDS servers were completed last week. Here's their list of new or improved features:

  • Full text index and search
  • Multiple B-Trees - this will allow us to deploy schemas as we move toward supporting schemas in SSDS
  • Asynch queries - this will help in exposing fanout queries across multiple containers
  • Logging and tracing improvements to help us manage and debug the service efficiently
  • Backup and restore services
  • Improvements to our Distributed Data Fabric for failover and friendly swapping between primary and secondary partitions

Hopefully, documentation for using the new features will appear quicker than that for SSDS v1.

Added: May 27, 2008

Steve Naughton Completes His Five-Part Permission Solution for ASP.NET Dynamic Data

UK Web developer Stephen Naughton has completed a five-part tutorial for adding role-based permissions to an ASP.NET Dynamic Data project on May 26, 2008:

  • Introduction - A DynamicData Attribute Based Permission Solution using User Roles.
  • Part 1 - Permissions Attribute (Metadata) Classes.
  • Part 2 - Sample Metadata for project.
  • Part 3 - The Helper Extension Methods.
  • Part 4 - Limit Tables shown on Default page and List, Edit & Details etc.
  • Part 5 - Generate Columns/Rows (using IAutoFieldGenerator)

    Following are two earlier posts on Dynamic Data topics:

  • DynamicData - Limit the Filter Fields
  • DynamicData - Automatic Column Update

    The ASP.NET Dynamic Data team's David Ebbo thanks Steve for his contribution in his Sample: Dynamic Data and attribute based permissions post of 5/7/2008.

    Added: May 27, 2008, Updated: May 27, 2008

    David Ebbo Explains How to Disambiguate ASP.NET Dynamic Data's PageRequestManagerServerErrorException JavaScript Error

    ASP.NET Dynamic Data turns on AJAX partial rendering using an UpdatePanel by default, which substitutes PageRequestManagerServerErrorException errors for more informative messages. In his Dynamic Data, AJAX and JavaScript errors post of May 25, 2008, David explains how to turn off partial rendering (open the Site.master file (at the root of the app) and set EnablePartialRendering="false") so you can see the real error message.

    Added: May 27, 2008

    ADO.NET Entity Framework v2 Wish List Started in MSDN Forum

    If you want to influence the feature list for the next version of the Entity Framework (EF), now's the time to add your request to the v2 Wish Lists - Add Yours Here thread that John Papa started in the ADO.NET Entity Framework and LINQ to Entities (Pre-release) forum. As of May 27, 2008 there were 13 replies in the thread.

    Added: May 27, 2008

    Diego Vega Explains How the EntityDataSource DataBinds Complex Types to ASP.NET Server Controls

    Diego's EntityDataSource's flattening of complex type properties post of May 24, 2008 is an expansion of the answer he give Julie Lerman in response to her Re: DataBinding Complex Type properties question of the same date in the ADO.NET Entity Framework and LINQ to Entities (Pre-release) forum. This post is an expansion of Diego's earlier EntityDataSource: To wrap or not to wrap post of May 13, 2008.

    In short, the EntityDataSource (EDS) flattens complex properties to enable two-way databinding to ASP.NET controls with Eval("Address.Street"), DataField = "Address.Street" and Bind("Address.Street") methods. An exception is one-way binding to ComboBoxes which requires an explicit projection with an alias, such as Select ContactID, Address.Street As Street.

    Added: May 24, 2008

    Francois Vanderseypen Explains Why He Didn't Use Entity Framework in his Sample Project

    In his Linq To Sql or Entity Framework? post of May 24, 2008 Francois says he decided not to use Entity Framework for the Northwind Factory v2.1 sample project for the following reasons:

    It seems Microsoft had the intention to ship the EF with VS2008 but a lack of time forced them to drop it and it’s now planned for SP1. Still even at this SP1-beta stage it’s somehow unacceptable that the multi-tiered solution, which should be there out of the box, is not present. Neither in L2S nor in the EF. It’s unacceptable for me in the sense that the whole world is now gravitating around multi-layered applications and any ORM or DAL system should enable this scenario (No out-of-the-box story!).

    EF appears to me to be closer to a Microsoft multi-tiered implementation than LINQ to SQL because it serializes complete object graphs with the updated SP1 DataContractSerializer (DCS). Danny Simmons demonstrated the feasibility of a multi-tier EF with the Perseus project and its EntityBag. The question now is whether Danny intends to rearchitect Perseus with DCS or stick with EntityBag.

    Added: May 24, 2008

    Dinesh Kulkarni on Object Tracking and LINQ to SQL DataContext Lifetime

    Dinesh explains that LINQ to SQL's object (instance) tracking feature is intended to prevent entities returned by successive queries from "stomping" on cached entity values. In his LINQ to SQL Tips 6: How to refresh given DataContext won't stomp on your objects post of May 23, 2008, Dinesh notes that you can overwrite the current values of one or more specified entities with the DataContext.Refresh method. However, he cautions that "the changes in the database for a given query can be:

      1. Newly inserted objects
      2. Updates of existing objects
      3. Deleted objects that were present in a previous execution of the same query

    Issuing the same query with the same DataContext takes care of the first. Refresh() can handle #2. But #3 requires a little more thought and computation. You could certainly use another DataContext to compare results."

    The issue resolves to selecting the appropriate DataContext lifetime, as recommended in his Lifetime of a LINQ to SQL DataContext post of April 27, 2008. If your application is stateful, consider separate DataContexts for online transaction processing (OLTP) and reference data. Dinesh's recommendations also apply to projects that use the Entity Framework.

    Added: May 24, 2008

    Rob Conery Completes MVC Storefront Parts 11 and 12 with Moq and Jimmy Bogard Proposes an nHibernate Fork 

    Rob's MVC Storefront, Part 11: Hooking Up The Shopping Cart And Components and MVC Storefront, Part 12: Mocking of May 23, 2008 continue the MVC Storefront saga. Part 12 uses Moq (a.k.a. LINQ for Mocks) to mock the repository's authentication data (Email, UserID, and Password).

    Rob acknowledges in Part 12 Jimmy Bogard's proposal in The MVC Storefront Challenge! post of May 20, 2008 to fork the code with nHibernate replacing LINQ to SQL. The comments include responses from several potential volunteers to help with the coding.

    Added: May 24, 2008

    Test Google Sites LINQ and Entity Framework Wiki Started

    I needed a place to catalog links to LINQ and Entity Framework resources, such as magazine articles, online help pages, and blog posts, that aren't date-sensitive. Google Sites opened as a free service to the public this week, so I set up a LINQ-EF site with pages of "announcements" for LINQ and EF-related topics. The LINQ-EF site isn't meant to compete with Troy Magennis's Hooked on LINQ Wiki; it doesn't include any original content.

    Google Sites is based on the JotSpot model but with many advanced JotSpot features missing. (Google acquired JotSpot in late October 2006.) It's simple to set up and navigate, and it substitutes an HTML editor for the arcane markup used by many wikis. It doesn't yet integrate with other Google Apps. It's certainly not the "SharePoint" killer that some bloggers claim, but it's probably good enough for my current needs.

    Added: May 24, 2008

    Dates, Times and Codes Added to Most Tech*Ed LINQ and Entity Framework Sessions

    The LINQ and Entity Framework Breakout and TLC Sessions at Tech*Ed Developers 2008 post was updated May 23, 2008 to include date, time and code data from the ADO.NET Team's Going to TechEd? Drop by and say Hi! blog of the same date.

    Apparently, only Tech*Ed 2008 Developer attendees have access to this added data.

    Added: May 24, 2008

    Has LINQ to SQL Reached Legacy Status Less than Three Months after Launch?

    LINQ to SQL was the only new data-access implementation to be included in Visual Studio 2008 when it "launched" with SQL Server 2008 and Windows Server 2008 in a series of "Heroes Happen Here" extravaganzas that started on February 27, 2008.

    Judging from my Is the ADO.NET Team Abandoning LINQ to SQL? post of May 21, 2008, Microsoft appears to have ceased further development of LINQ to SQL, based on the lack of new and promised features in the LINQ to SQL SP1 Beta.

    Repeated from: LINQ and Entity Framework Posts for 5/19/2008+

    Updated 5/23/2008 with a response to a comment from Andres Aguiar and Julie Lerman's Damien Guard joins the LINQ to SQL team as a developer post of the same date.

    Quick Links to VS 2008 SP1 Beta Docs

    My VS 2008 and .NET Framework 3.5 SP1 Beta Documentation and Forum Links of May 22, 2008 has links to LINQ, Entity Framework and related topics in the unsearchable (and unindexed) MSDN Library.

    Marcin Dobosz on Customizing ASP.NET Dynamic Data Validation Metadata

    Marcin's Dynamic Data samples: Custom metadata providers post of May 23, 2008 explains how to "programmatically add [data validation] metadata attributes to an in-memory store before you register your model with the Dynamic Data runtime in Global.asax." This sample replaces the XML-based metadata provider for the December 2007 CTP.

    His earlier Dynamic Data samples post contains a list of the current and forthcoming ASP.NET Dynamic Data samples. (I added a "Where's the beef?" comment to this post.)

    A Solution for the KB944899 Problem When Attempting to Install VS 2008 SP1 Beta

    Wally McClure found the Visual Studio 2008 Hotfix Cleanup Utility on the MSDN Code Gallery. This small *.exe file removes KB944899, if present, and removes the registry keys that cause the problem.

    Matt Manela Explains LINQ to SQL's Optimistic Concurrency Management Features

    In his Intro to LINQ to SQL Optimistic Concurrency post of May 22, 2008, Matt explains the significance of the UpdateCheck.Always, UpdateCheck.Never, and UpdateCheck.WhenChanged properties when managing updates with optimistic concurrency conflicts.

    Scott Allen Analyzes Rob Conery's Problems with LINQ to SQL Lazy Loading

    Scott left a comment to my "Rob Conery Runs into a LINQ to SQL Corner with his Repository Model" topic of LINQ and Entity Framework Posts for 5/19/2008+ that Rob's conclusion it was LINQ to SQL's fault: "I'd say that requires more investigation. Doesn't sound correct."

    His Rob's Not So Lazy MVC Storefront post of May 21, 2008 uncovers the real culprit, a type conversion of the IList<Product> property.

    Kevin Lewis Rewrites His UPS Webservice Rate Calculator with LINQ to XML and VB Literals

    His LINQ to UPS to Calculate Shipping Rates post of May 22, 2008 contains the full source code for his updated GetShippingMethodsFromWeb function.

    Samir Bajaj Demonstrates How to Use LINQ to SQL with Table per Type Inheritance

    From the How Did I Miss That? department: Back on April 2, 2008, Samir posted TPT with LINQ to SQL on his MSDN blog that I wasn't tracking at the time. He discusses the three common mapping strategies for object hierarchies: Table per Hierarchy (TPH), Type per Type (TPT) and Table per Concrete Type (TPCT). LINQ to SQL has out-of-the-box support for TPH only. But Samir demonstrates that you can map a TPT hierarchy "using the built-in TPH support and a bit of T-SQL code."

    The sample code is available here: TPT with LINQ to SQL.

    Marco De Sanctis Asserts That It's Not Always a Wise Choice to Eager-Load Associated Entities in LINQ to SQL Projects

    Most developers using LINQ to SQL as the data layer eager-load associated entities to minimize round trips to the database. In When Lazy Loading associations is useful of May 22, 2008, Marco describes two scenarios where lazy loading may be beneficial.

    Marco De Sanctis Wraps LINQ to SQL's Data Context in a Generic Unit of Work Instance for Caching by ASP.NET

    His Linq To Sql in real word Web applications post of May 20, 2008 shows you how to wrap LINQ to SQL's Data Context in a generic Unit of Work instance to emulate nHibernate's SessionPerConversation pattern. His post includes a link to download the sample code.


    London seo said...

    These are highly informative and helpful.Thank you for sharing this fine article. Very inspiring!