Tuesday, June 03, 2008

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

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

Updated 6/4/2008: See Update tag below

Julie Lerman to Spray Graffiti on Web Pages at Tech*Ed Developer 2008 (Maybe) (For Sure)

Update 6/3/2008 6:30 AM PDT: According to her TechEd Ask The Experts: Website Graffiti? Silverlight 2.0 Annotation at the Vista booth post of June 1, 2008, Julie willwas to

be doing a fun Ask the Experts session at the Windows Vista booth Windows Vista at TechEd Developer 2008 “Ask the Experts” Website Graffiti?  Drawing and Annotation with Silverlight on Tuesday June 3rd 1:00-2:00

Julie's How hard could it be to get to TechED? post of June 2 illustrates the joys of today's airline travel. I just received a message that she caught a 6 o'clock flight to Orlando Tuesday morning. This assumes she gets to Orlando by then.

Read her The "body clock" I didn't know I had post at 5:15 EDT today from Burlington airport.

Don't miss Julie's session!

Workaround for Duplicate Object References in ADO.NET Dynamic Data Custom Pages for Web Applications

My Eliminate Ambiguous Object References when Customizing ADO.NET Dynamic Data Pages in Web Apps post of June 2, 2008 shows you how to recover from multiple errors after you copy a template (List.aspx, Edit.aspx, etc.) from the PageTemplates folder to a subfolder of the CustomPages folder that's named for the EntitySet you're displaying, editing or both.

The errors are similar to those shown below and occur only in Dynamic Data Web Application projects; Dynamic Data file-system Web Sites aren't affected:

A Broad-Brush View of ADO.NET Data Services (a.k.a. Project Astoria)

My "ADO.NET Data Services: Access data in the cloud with REST" TechBrief for the June 1, 2008 issue of Redmond Developer News complements the more extensive "Manipulate Data in the Cloud with ADO.NET" article I wrote for Visual Studio Magazine's May 2008 issue.

Click here for the large version of the article's diagram.

Steve Naughton Explains How to Use ASP.NET Dynamic Data's  DisplayColumnAttribute

The DisplayColumn attribute lets you specify the primary key column supplied as the foreign key to tables, as well as the sort direction. If you're using Northwind, you'll need to apply the attribute to the Orders table's OrderMetaData class as shown below to prevent the CustomerID value from appearing in place of the OrderID in Order_Details displays.

[MetadataType(typeof(OrderMetaData))]
public partial class Order { }
// By default, the first string column (CustomerID) displays foreign key values
// Set the display column and sort column to OrderID and sort in descending order  
[DisplayColumn("OrderID", "OrderDate", true)]    
public class OrderMetaData { … }

The preceding code should display the Order objects in descending order so it's easier to pick the right OrderID from the dropdown list.

Steve's DynamicData Sorting - FilterUserControl and ForeignKey_Edit.ascx user controls post of June 2, 2008 tells the whole story.

Update 6/4/2008: Notice the added term “should” above. Specifying a descending sort by OrderDate or OrderID doesn’t work for Order or Order_Detail entities in my two test harnesses. More in the DisplayColumn's SortDescending Attribute Doesn't Appear to Work in 5-23 Bits thread of the ASP.NET Dynamic Data Forum.

It turns out that the DisplayColumn() attribute’s sorting arguments apply only to the sequence of dropdown lists of foreign key values (by design). To set the sort order of Orders and Order_Details lists, I added the line shown bold in their custom List.aspx page’s Page_Init event handler, as shown here:

protected void Page_Init(object sender, EventArgs e)
{
    DynamicDataManager1.RegisterControl(GridView1, true /*setSelectionFromUrl*/);
    GridView1.Sort("OrderID", SortDirection.Descending);
}

Dinesh Kulkarni Demonstrates Simple Last Writer Wins LINQ to SQL Updates

Dinesh's LINQ to SQL Tips 7: Minimal update when you don't want optimistic concurrency check post of June 1, 2008 demonstrates the syntax for updates you make by attaching to a DataContext an entity whose members have UpdateCheck = Never set. In this case you don't need original values and concurrency conflicts are disregarded.

Scott Guthrie Confirms that the Latest MVC Preview Bits Support Web Developer Express

Previous drops of the ASP.NET MVC preview required VS 2008 Basic or higher. Scott's ASP.NET MVC Support with Visual Web Developer 2008 Express post of June 1, 2008 notes that Preview 3 of May 27, 2008 works with Web Developer Express.

Steve Naughton Shows How to Validate DateTime Values in ADO.NET Dynamic Data Projects

Steve adds a custom validator to the DateTime_Edit.ascx UserControl in his DateTime Validation in DynamicData post of June 1, 2008 to invoke DateTime.TryParse(DateText) in the CustomValidator1_ServerValidate() event handler.

An alternative is to use a RegularExpressionAttribute with a suitable RegEx string, such as:

[RegularExpression(@"^(((((0[13578])|([13578])|(1[02]))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(3[01])))|((([469])|(11))[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9])|(30)))|((02|2)[\-\/\s]?((0[1-9])|([1-9])|([1-2][0-9]))))[\-\/\s]?\d{4})(\s(((0[1-9])|([1-9])|(1[0-2]))\:([0-5][0-9])((\s)|(\:([0-5][0-9])\s))([AM|PM|am|pm]{2,2})))?$",
    ErrorMessage = "Date format required is MM/dd/yyyy [hh:mm AM/PM]")]
public object OrderDate { get; set; }

There's a long How to validate dates? related thread in the ASP.NET Dynamic Data Forum.

John Markoff Reports about UC Berkeley's Tribute To Jim Gray

John's A Tribute to Jim Gray: Sometimes Nice Guys Do Finish First NY Times story of June 1, 2008 describes the event held on June 1 at the University of California's Berkeley campus:

Roughly 600 friends and colleagues attended two separate events on campus intended to capture his technical and personal contributions. The audience was a cross-section of the computer industry’s best and brightest, and speaker after speaker repeated the point that virtually everyone thought that Dr. Gray was one of their closest friends, only to discover after he disappeared that that had been true for literally thousands of people.

Markoff knew Jim because the NY Times' San Francisco office was once in the same building as Microsoft Research.

Wired Magazine's Steve Silberman wrote a detailed "Inside the High Tech Hunt for a Missing Silicon Valley Legend" story, which ran in the July 24, 1907 issue.

Contemporaneous posts OakLeaf blog posts are "Friends of Jim" Halt Volunteer Search for Jim Gray of February 17, 2007 and U.S. Coast Guard Searching for Jim Gray off San Francisco Coast of January 29, 2007.

Philip Patrick Recounts Problems with Entity Framework, SQL Server CE 3.5 and Identity Columns

Philip's ADO.NET Entity Framework, SQLCE and identity columns post of May 30, 2008 says:

Now MS only recently added support for SQLCE in the framework, so its kind of beta inside beta. Some features are not working properly or missing, as for example, support for identity columns. While SQLCE provides support for auto-generated columns, the framework doesn't yet have it. And of course all my IDs in tables are auto-generated integer values, e.g. identity.

Until the fix arrives, Philip offers a fairly simple workaround.

"Computer Overlord" Abandons LINQ to SQL for nHibernate

It's not clear exactly what this user found lacking in LINQ to SQL as reported in NHibernate, the original and better than LINQ to SQL.. for now of June 1, 2008 or why nHibernate is better. An example:

The reason I found L2S so attractive was that the designer did all the heavy lifting for me and generated all the code. I realise now that L2S is just Microsoft’s version of NHibernate, and that most of the things I didn’t like with L2S aren’t an issue with NHibernate as long as you are happy to customise a code generator.

0 comments: