LINQ and Entity Framework Posts for 2/11/2008+
Note: This post is updated daily or more often, depending on the availability of new articles.
Updated: 2/15/2008 for the Amazon S3 outage and 2/16/2008 for the reason for the outage. See the "Justin Etheredge Offers Preview of LINQ to [Amazon] SimpleDB" topic.
Danny Simmons Deals with the ObjectContext Lifetime Dilemma
Danny's Context Lifetimes -- Dispose or Reuse? post of 2/17/2008 (yes, a Sunday post) attempts to answer its title's question based on "understanding the overall pattern of your app." (Other than "too slow" I suppose.)
On the whole, Danny's criteria for reusing and disposing also can be applied to LINQ to SQL DataContext objects, which are lighter weight.
The question, which I've asked in the comments, is how will the (hopefully) imminent ASP.NET EntityDataSource server control affect the recommendations?
Added: 2/17/2008
David DeWinter Starts Project to Synchronize LINQ to SQL DBML Files with Database Schema Changes
David's LINQ to SQL and Database Schema Sync post of February 16, 2008 describes his objectives in starting a project to keep his "generated entity classes in sync with the current database schema" by a mechanism other than clearing the designer surface and starting over. He cites many types of manual adjustments to the entities in the designer that must be made to many tables each time you drop them on the designer surface. The goal is to maintain a record of systematic changes for repetition on both unchanged and altered or added tables.
His second The LINQ to SQL Metamodel post of the same day describes his use of Project NORMA to enable Visual Studio 2008 to render Object Role Modeling (ORM) diagrams of Database, Connection, Table, Type, Column, Association, Function and TableFunction elements. (Some of the diagrams are amazingly complex.)
Note: The Entity Data Model's Model Browser has a similar feature called Update Model from Database that opens the Entity Data Model Wizard that lets you select items to add. The Wizard automatically updates existing and deleted items. My tests so far with the Beta 3 version have resulted in non-displayable models.
Added and subscribed: 2/16/2008
Dare Obasanjo Seconds the ADO.NET Entity Data Team's Decision to Adopt AtomPub for Updates
In his ADO.NET Data Services (Astoria) Adopts AtomPub post of February 16, 2008, Dare says:
I'm glad to see Microsoft making a huge bet on standards based, RESTful protocols especially given our recent history where we foisted Snakes On APlane on the industry. [Emphasis Dare's.]
However since AtomPub is intended to be an extensible protocol, Astoria has added certain extensions to make the service work for their scenarios while staying within the letter and spirit of the spec.
Dare then goes on to analyze in his Thoughts on Google's Proposal for Granular Updates in AtomPub post of February 16, 2008 Joe Gregorio's How to do RESTful Partial Updates proposal of February 15, 2008 for updating specific properties of an entry without retrieving and returning the entire entry. Dare's primary complaints are:
The main problem is that it changes the expected semantics of HTTP PUT in a way that not only conflicts with how PUT is typically used in other HTTP-based protocols but also how it is used in AtomPub. It's also weird that the existence of xml:id in an Atom document is now used to imply special semantics (i.e. this field supports direct editing). I especially don't like that after all is said and done, the server controls which fields can be partially updated or not which seems to imply a tight coupling between clients and servers (e.g. some servers will support partial updates on all fields, some may only support partial updates on atom:title + atom:category while others will support partial updates on a different set of fields). So the code for editing a title or category changes depending on which AtomPub service you are talking to.
Dare's solution:
If a field is important enough that it needs to be identifiable and editable then it should be its own resource. If you want to make it part of another resource then use
atom:link
to link both resources.
Added: 2/16/2008
Julie Lerman Creates ADO.NET Data Services PopFly Mashup
Julie's presenting a Web Mashups with ADO.NET Data Services session at DevConnections, so she decided to create a PopFly mashup with the aid of the Popfly Explorer plugin for VS 2008 [Express].
She recounts her experiences creating a simple read-only client with the NewsReader block in her ADO.NET Data Services + PopFly post of February 15, 2008.
Added: 2/15/2008
Microsoft Appoints Scott Guthrie Corporate Vice President for the .NET Developer Platform
Scott received a well-deserved promotion in Redmond's latest management reshuffling, as noted in a February 14, 2008 press release, Microsoft Announces New, Expanded Roles for Key Executives. From the release:
Scott Guthrie, corporate vice president, .NET Developer Platform. Previously general manager, Guthrie will continue to oversee several development teams responsible for delivering Microsoft Visual Studio developer tools and Microsoft .NET Framework technologies for building client and Web applications.
Congratulations, Scott. Hopefully, the rise in grade won't stem the flow of your great tutorial and useful linkblog posts. As I said in a comment to Joe Wilcox's Microsoft Puts on Midlife Executive Bulge post of February 15:
Of all the execs whose titles Microsoft bumped up yesterday, not one deserves a promotion more than Scott Guthrie. Scott's enthusiasm for the .NET development platform, as evidenced in his blog and technical presentations, continue to attract programmers of all skill levels to Visual Studio 2008 and .NET 3.5.
Other developer-oriented groups would do well to clone Guthrie's approach to marketing their platforms.
Microsoft also boosted Scott's boss, S. "Soma" Somasegar, from Corporate to Senior Vice President:
S. Somasegar, senior vice president, Developer Division. Previously corporate vice president, Somasegar will continue to oversee all developer-related languages, tools and platforms within Microsoft. He also leads Microsoft India Development Center and Microsoft Canada Development Centre.
Added: 2/15/2008
Updated 2/16/2008: .NET Rocks! interviewed Scott for show #316 (2/14/2008) about IIS 7.0, Silverlight 2.0, MIX 08 and other hot topics. Scott's 34-minute segment starts at 04:00.
Justin Etheredge Offers Preview of LINQ to [Amazon] SimpleDB
Justin's been working on LINQ to SimpleDB since shortly after Amazon opened SimpleDB's limited beta. His LINQ To SimpleDB Issues post of December 31, 2007 (before he had access to the beta) details the issues with dealing with numbers when the database only supports strings. I've missed Justin's LINQ-related posts on his CodeThinked blog up until now because it doesn't have high visibility for "LINQ" in search engine results.
Justin released LINQ to SimpleDB Alpha 1 (source code and runtime binary) to CodePlex on January 23, 2008 under the Microsoft Public License (Ms-PL). His LinqToSimpleDB Preview post of January 19, 2008 offers operating instructions. The Releases page describes the included functionality as:
- Query SimpleDB Items by Attributes
- Retrieve Attributes for items
- Query items by Name
- Create and Delete Domains
- Create and Delete Items
- Create and Delete Attributes
Note: My Amazon Announces Beta of SimpleDB Web Services in the Cloud of Post of December 14, 2007 and Dare Obasanjo's Amazon SimpleDB: The Good, the Bad and the Ugly post of December 21, 2007 analyze SimpleDB's feature set.
I plan to give LINQ to SimpleDB a test drive as soon a SimpleDB beta test slot becomes available.
Added: 2/14/2008
Updated 2/15/2008: All Amazon Web services (including SimpleDB) appear to have suffered a massive outage at about 4:30 AM Pacific time according to Nicholas Carr's post of this morning. The problem was reported to have been corrected at 7:30 AM but some users were still reporting problems at 8:30 AM, according to Michael Krigman's Amazon S3 web services down. Bad, bad news for customers. blog, "Rearranging the Deck Chairs: IT Project Failures."
Amazon's Service Level Agreement for S3 (which presumably would apply to SimpleDB when it's out of beta) is 99.9% availability during a monthly billing period. Assuming 30.5 days/month, 0.1% downtime is 0.732 hours.
Updated 2/16/2008: Nick explains in today's Why S3 failed update that:
It was not a hardware failure. Rather, the service's authentication system, which verifies the identity of a user, became overloaded with user requests. As one person explained to me, it amounted to a kind of accidental DDoS (distributed denial of service) attack, and Amazon didn't have enough capacity in place in one of its data centers to handle the surge.
Nick's post includes the official reason in a message from Amazon.com.
Mike Taulty Tabulates Entity Framework's Mapping Capabilities
Mike's ADO.NET Entity Framework Mapping Table post of February 14, 2008 begins with:
One of the things that's been really bothering me for quite a while now is the aspect of mapping in the Entity Framework.
Technical things can trouble me. I like to get them into my head, understood and then I can move on. I have a very, very bad memory and the only way I can remember anything is by understanding how it works and then I find it relatively easy to piece back together at a later point.
Strange that Mike should mention this. I'm bothered by the same questions about EF's mapping capabilities, despite the fact that I use them almost every day. I also have the same memory problem. So Mike put together a list of these capabilities with details examples. Here's a list of what he covers:
- Renaming an Entity Type
- Renaming an Attribute (although I'd call it Renaming a Property)
- Removing an attribute (ditto)
- Specifying a default value for an attribute that does not have a default value
- Overriding a default value for an attribute that has a default value
- Changing the data type of an attribute
- Changing the nullability of an attribute
- Multiple store tables, single entity type
- Single store table, multiple entity types or entity sets
For all my sample projects that use EF/EDM, especially those based on Northwind, I use:
- To singularize Entity Types, leaving the Plural for Entity Collections/Sets
- To singularize the name of navigation properties for Many:1 associations
- To remove images (e.g., Category.Picture and Employee.Photo)
But I hadn't thought of using 5 to add Today as Order.OrderDate's default value or 7 to change the nullability of value-type properties, such as Order.OrderDate, Order.Freight, Product. UnitPrice, etc. The latter might solve some of my issues with EF projects in VB (e.g. performance problems with COALESCE and no support for the Coalesce operator by the VB version of ADO.NET Data Services clients -- see below). Minimizing Nullable<T> data types also minimizes Nullable`1[System.Decimal]" type declarations in ADO.NET Data Services' Atom-formatted payloads.
Update 2/14/2008: Default values are constants of the property's type, so specifying the DateAndTime.Today property doesn't work. (Nor does it throw an exception).
I'd say the preceding list would make a good start for a series of ADO.NET Team blog posts, as well as the final EF documentation.
Added: 2/14/2008
Pablo Castro: ADO.NET Data Services and the Atom Publishing Protocol
Pablo explains the Project Astoria team's approach to adopting the Atom Syndication Protocol (Atom, RFC 4287) and Atom Publishing Protocol (APP, RFC 5023) as data-exchange (payload) formats in his AtomPub support in the ADO.NET Data Services Framework post of February 13, 2008.
The Astoria Team plans to post its proposed extensions and application-level features for discussion on the atom-syntax and atom-protocol mailing lists. Read more about the pending issues here.
Added and updated: 2/14/2008
Tercer Planeta's Working on a LINQ-Enabled Application Framework
Jose Marcenario and Benjamin Eidelman, principals of Tercer Planeta (Third Planet, a .NET consulting firm in Argentina), have determined that "it would be great to have a LINQ 'Queryable' data access layer." So they've "started to analyze LINQ-to-SQL integration in Enterprise applications of different scale."
Benjamin's initial post, First Thoughts on Designing a LINQ-enabled Application Framework of February 13, 2008, deals with issues arising from LINQ to SQL's infamous lack of "an out-of-the-box n-tier story" because DataContext objects aren't serializable.
He points to Manuel Bauer's InterLINQ project on CodePlex that serializes an expression tree and returns the query result. (InterLINQ is destined to become a component of the poor man's Model Driven Architecture for .NET project from HSR Hochschule für Technik Rapperswil, Switzerland' .NET Competency department). However, it doesn't appear that Tercer Planeta will take the InterLINQ route.
At the end of the post, Benjamin says:
These days we're starting to see the light and the end of tunnel, with custom tools and code we started to write.
More on this on following posts...
Added: 2/14/2008
VB-Specific Bugs in ADO.NET Data Services CTP
Today's Fix for "Known Bug" when Creating ADO.NET Data Services with Visual Basic and a Web Application post updates an ASP.NET 3.5 Extensions Preview Released post of December 10, 2008 included a "Data Services (Project Astoria)" topic that itemizes some errors in the QuickStart instructions for creating an ADO.NET Data Service.
The need to do a fixup by removing the default namespace for a VB ADO.NET Data Services project that uses a ASP.NET Web Application (rather than a file-system Web site) turned out to be a known but unpublicized bug.
There's another VB-related bug that's described in my LINQ Query Expression Fails in VB with 'Coalesce' Not Supported Error, C# OK post in the ADO.NET Data Services (Pre-release) forum. I'm waiting for a reply indicating whether that problem is known.
While I'm griping, the numeric operators documentation shows lteq and gteq instead of the correct le and ge for <= and >=, respectively. There's also an issue with the use of $expand in LINQ to REST and WebDataQueries, which has known problems.
Errata for docs and lists of supported and unsupported operators, etc., would be very useful for ADO.NET Data Services pilgrims (like me.)
Added: 2/13/2008
Charlie Calvert: Using the Expression Tree Visualizer
The latest in Charlie's LINQ Farm Seed series is LINQ Farm Seed: Using the Expression Tree Visualizer of February 13, 2008. This post gives detailed instructions on how to download the visalizer and use it to view the expression tree for a simple lambda function.
Added: 2/13/2008
Julie Lerman Records Entity Framework Podcast for .NET Rocks!
Julie's Just recorded DotNetRocks about Entity Framework post of February 12, 2008 describes her one-hour interview with Carl Franklin and Richard Campbell about the Entity Framework.
A major concern voiced in her podcast: DBAs' reluctance to accept dynamic SQL queries from Entity Framework or LINQ to SQL and ignorance of both implementations' capability to use stored procedures for all CRUD operations.
Mark your calendars: The podcast will be aired on February 26, 2008.
Added: 2/13/2008
James Newton-King Publishes LINQ to JSON Beta
According to James' LINQ to JSON beta post of February 11, 2008, LINQ to JSON is an API that's similar to LINQ to XML, not a LINQ provider. It enables a declarative syntax for writing JSON code and a query syntax for reading it. The post provides a simple RSS channel/items structure as an example.
LINQ to JSON is part of James' larger Json.NET project on CodePlex. According to the project's home page, Json.NET offers:
- Lightning fast JsonReader and JsonWriter
- The JsonSerializer for quickly converting your .NET objects to JSON and back again
- Json.NET can optionally produce well formatted, indented JSON for debugging or display
- Attributes like JsonIgnore and JsonProperty can be added to a class to customize how a class is serialized
- Ability to convert JSON to and from XML
Json.NET 2.0 Beta 1 released on 2/11/2008 includes the following new features, changes, and bug fixes:
- New feature - LINQ to JSON!
- New feature - Ability to specify how JsonSerializer handles null values when serializing/deserializing.
- New feature - Ability to specify how JsonSerializer handles missing values when deserializing.
- Change - Improved support for reading and writing JavaScript constructors.
- Change - A new JsonWriter can now write additional tokens without erroring.
- Bug fix - JsonSerializer handles deserializing dictionaries where the key isn't a string.
- Bug fix - JsonReader now correctly parses hex character codes.
Added: 2/13/2008
Bill Horst Struggles to Emulate a FULL OUTER JOIN with LINQ to SQL
Bill's Converting SQL to LINQ, Part 9: Full Outer Join post of February 12, 2008 demonstrates creating the equivalent of a T-SQL FULL OUTER JOIN command with one initial LINQ query and two concatenated subqueries.
Apparently, this is the last of Bill's posts unless users suggest a different topic.
Links to all nine topics are available here.
Added: 2/12/2008
Alex James Reaches Part 4 of His Bulk Updates with Entity Framework Saga
If you want to avoid bringing a large number business objects into memory for bulk updating, Alex has the solution. In his Rolling your own SQL Update on top of the Entity Framework - Part 4 post of February 12, 2008, he shows you how he builds the final UPDATE [Table] SET Column = value, .... WHERE Key IN (...) query from Part 3's GetQueryInfo() method.
What would be interesting is a comparison of the performance of Alex's approach with the out-of-the-box bring-the-objects-into-memory-make-changes-and-invoke-SaveChanges() approach.
Following are links to Alex's three previous parts:
- Rolling your own SQL Update on-top of the Entity Framework - Part 3
- Rolling your own SQL Update on-top of the Entity Framework - Part 2
- Rolling your own SQL Update on-top of the Entity Framework - Part 1
Added: 2/12/2008
Kathleen Dollard Moves from XSLT to LINQ to XML Literals for Code Generation
dnrTV's Kathleen Dollard on Code Generation in .NET video of February 1, 2008 describes Kathleen's recent development efforts in moving from XSLT to LINQ to XML literals. You can see an example of a language specific LINQ to XML literal template starting at 15:30. Language-independent (C# and VB) template generation examples follow.
Despite the fact that Kathleen doesn't like Microsoft's SingleFileGenerator approach, she plans to move to .edmx files for templates because they enable mapping between tables and objects.
Beth's two earlier dnrTV videos about VB 9.0 and C# 3.0 are at:
- Kathleen Dollard on Comparing C# and VB in .NET 3.5 Part 2
- Kathleen Dollard on Comparing C# and VB in .NET 3.5 Part 1
Thanks to Beth Massi for the heads up.
Added: 2/12/2008
Brian Dawson Continues His Entity Framework Performance Series
In his Exploring the Performance of the ADO.NET Entity Framework – Part 2 post of February 11, 2008, Brian starts by describing caching of Entity SQL queries and its dramatic affect on query execution time: 179 ms. for the first vs. 15 ms. for subsequent executions. The same LINQ to Entities query executes in 202 ms. vs. 18 ms.
Brian then goes on to describe the benefit of compiling LINQ queries, which increases the initial execution time to 305 ms. and reduces subsequent execution times to 15 ms. (Brian says "It’s true that in this case subsequent executions of the compiled LINQ query are slower than those of the non-compiled LINQ query," however, the data indicates otherwise.
Changing the MergeOption to no tracking has a dramatic affect on subsequent executions of compiled queries: 3 ms. vs 15 to 17 ms.
Brian concludes:
- Initial creation of the ObjectContext includes the cost of loading and validating the metadata.
- Initial execution of any query includes the costs of building up a query cache to enable faster execution of subsequent queries.
- Compiled LINQ queries are faster than Non-compiled LINQ queries.
- Queries executed with a NoTracking merge option work well for streaming large data objects or when changes and relationships do not need to be tracked.
Added: 2/12/2008
Stefan Sedich Discovers Cause of Slow LINQ to SQL Performance with VB
Stefan's Different SQL between VB.NET and C# LINQ to SQL SOLVED!! post of February 12, 2008 describes the cause of VB's added (COALESCE(CASE ... )) clauses: VB treats database fields that allow nulls differently from C#. Note that Northwind tables allow nulls in foreign-key fields that would throw referential integrity exceptions if set to null.
See the "Dramatically Poorer Performance of VB Than C# LINQ to SQL Queries" topic of LINQ and Entity Framework Posts for 2/4/2008+.
Added: 2/12/2008
DinnerNow.NET Updated for VS 2008 RTM
The open-source DinnerNow.NET sample ASP.NET application has been updated to .NET 3.5 and VS 2008 RTM. According to the CodePlex release site, the following new .NET 3.5/VS 2008 features have been added:
- LINQ to SQL
- WF/WCF integration
- IIS7 & Windows Activation Services (WAS) hosting for WCF services
- WCF 3.5 Syndication Services
- WCF on the .NET Compact Framework 3.5
The DinnerNow 2.5 release has also been tested for compatib[ility] with Windows Vista, Windows Vista SP1, and Windows Server 2008 RTM.
You can download the bits from DinnerNow.net on CodePlex.
The Visual Studio 2008 Training Kit uses DinnerNow.NET in several of its online Labs.
Thanks to Guy Burstein for the heads-up.
Jim Wooley Upgrades the Personal Web Starter Kit's Data Tier from ADO.NET to LINQ to SQL
The Personal Web Starter Kit (PWSK) is a sample ASP.NET application that lets users organize individual photo files into albums stored in an SQL Server Express database. You can download the original version here.
Jim's Personal Web Starter Kit LINQed up post of February 10, 2008 shows you how he refactored PhotoManager.vb to replace ADO.NET SqlClient stored procedure calls with LINQ to SQL's parameterized dynamic queries. You can read more about Jim's PSWK version and download the upgraded project at his LINQ enabled Personal Web Site Starter kit site in the MSDN Code Gallery.
Jim also provides a set of guidelines for migration from SqlClient to LINQ to SQL in his LINQ Migration hints of the same date.
0 comments:
Post a Comment