Steve Michelotti

A .NET Developer's Toolbox

  Home  |   Contact  |   Syndication    |   Login
  199 Posts | 0 Stories | 1106 Comments | 51 Trackbacks

News

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers




Google My Blog

What I'm Reading:

Shelfari: Book reviews on your book blog

Tag Cloud


Archives

Post Categories

Code

Publications

December 2007 Entries

Recently I've done a series of posts all related to using Linq in a tiered application: Linq Table Attach() Linq Table Attach() based on timestamp or row version Handling Attach() with child entity objects Exploring DataContext in more depth The various posts (which have been influenced by this MSDN article) have focused on a DataContext that looks like the diagram below. The Contact class generated has a child collection property of Addresses which is of type EntitySet<Address>. This distinction ......

In a previous post here, I discussed implementation of Attaching Linq entities to a DataContext. In that post, I showed an implementation of utilizing a Detach() method that I originally based on this post here. The implementation boils down to the need to reset EntityRef<> references back to their default - otherwise, it will try to attach the parent objects (which is often not the goal of your code as this is often just reference data). Consider the DataContext below: The fundamental problem ......

This exception using the Linq Attach() method is somewhat perplexing at first: System.NotSupportedException: An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext. This is not supported. This blog post here *sort of* pointed me in the right direction. But I found the *WHY* confusing and I found the example confusing. The following is my implementation of the suggested solution from the previous post. First, consider the following ......

In a previous post here, I showed an example of using the Attach() method in conjunction with a Timestamp column in your database table. In listing options that are supported, Microsoft's documentation states: "Optimistic concurrency based on timestamps or RowVersion numbers." So what are some alternatives to using a Timestamp column in your SQL Server database? It turns out, this is pretty simple. Two other alternatives are using a DateTime or a unique identifier column. DateTime Last Updated The ......

The ability to use live Linq queries right in your UI makes for great demo's, but it doesn't bear a striking resemblance to a real-world, professional application which uses tiers. In traditional n-tier applications, you want to have a strong "separation of concerns" and encapsulate your business layer, your data layer, and your UI layer distinctly. One of the nice things about Linq is that the flexibility is huge. If you want to do live queries in your UI, fine. If you want to encapsulate Linq queries ......