December 2008 - Posts
There are many ways to customize a ASP.NET Dynamic Data site, which can sometimes be a bit overwhelming to newcomers. Before deciding what customization makes sense for you, it is important to understand the two major buckets that they fall into: Generic customization : things that apply generically to any table/column. Schema specific customization : things that apply to specific tables and/or columns. They can both very useful depending on your scenario, but it is important to understand how they are different in order to make the right choices. The rule of thumb is that you want to stay in the world of generic customization whenever possible, and only use the schema specific customization when you have to. Doing this will increase reusability...
For the longest time, I had set my blog subtitle to “Dynamic Data and other ASP.NET topics”, which some might argue would not have won any originality contests. On the bright side, it was a fine match for my equally original blog title: “David Ebbo's blog”. So I went on a quest for a new subtitle as part of my 2009 New Year resolutions (ok, it’s the only one so far). As for changing the Title itself, I’ll save that for New Year 2010. My first stop in this memorable journey resulted in the use of the extremely witty word ‘Ebblog’. While undeniably cool, I somehow decided to pass on it. The future will probably not tell whether it was a good move. Still looking to capitalize on my uniquely catchy last name, I came up...
Most Dynamic Data web sites typically only use a single database, with either a Linq To Sql or Entity Framework model over it. But in some cases, you need your site to use multiple databases/models. This came up today in this forum thread . In fact, the original poster (Chris) is the one that came up with a good solution, and that’s what my sample app in this post is doing (so credits to him!). The full sample is attached at the end, so feel free to get it now if you prefer! Note that I’ll cheat a little bit, by doing the following: I’ll only use one Northwind database (bear with me here!) I’ll create both a Linq To Sql and an Entity Framework model over it The main reason for doing this is to avoid having to include two MDF files in the sample...
This post was prompted from a forum thread in which the user wanted to display database errors in a Dynamic Data page, instead of the default behavior that ends up with an unhandled exception (or an AJAX error with partial rendering). When using Linq To Sql, this can be done fairly easily in a couple different ways, by wrapping the exception in a ValidationException. To do it globally for a DataContext, you can do something like this: public override void SubmitChanges(System.Data.Linq. ConflictMode failureMode) { try { base .SubmitChanges(failureMode); } catch ( Exception e) { throw new ValidationException ( null , e); } } And to do it with more granularity, you can use one of the partial methods on the DataContext. e.g. partial void DeleteCategory...
More Posts