ASP.NET IronPython

Browse by Tags

All Tags » Dynamic Data (RSS)
Peter Blum’s new blog and his cool new data source controls
Peter Blum has been well known is the ASP.NET world for many years for writing a whole suite of powerful controls, which you can read all about on his site .  One thing that was missing on Peter’s resume is that he never had a blog.  Well he started one earlier this month, and is making up for the lost time in a big way, with already 11 posts!  And we’re not talking about small posts that just point to other people’s stuff (unlike this post I suppose!), but real with useful meaty content.  Make sure you check out his blog at http://weblogs.asp.net/peterblum/ .  I hope he keeps the good stuff coming! In particular, Peter has been working hard on some interesting data source controls that work with Visual Studio 2010. ...
Using an Associated Metadata Class outside Dynamic Data
A while back, I blogged about how ASP.NET Dynamic Data apps can uses an Associated Metadata class (aka a ‘buddy’ class) to add metadata attributed to properties defined in a generated class. It’s a mostly ugly thing that was made necessary by limitations of the C# and VB.NET languages: they don’t let you add attributes to properties defined in another partial class. What I didn’t mention there is that this ‘buddy’ class mechanism is actually not specific to Dynamic Data apps, and can in fact be used anywhere. Since I’ve recently heard of several cases of users trying to do something similar, I’ll describe how it’s done. If you’re familiar with TypeDescriptionProviders (which have been around since ancient times), this will look very trivial...
Using a DomainService in ASP.NET and Dynamic Data
One of the big things that I discussed in my MIX talk is the new DomainDataSource control.  It is currently available in Preview form as part of ASP.NET Dynamic Data 4.0 Preview 3 .  This can be confusing, because even though Dynamic Data makes use of DomainDataSource, DomainDataSource is absolutely not tied to Dynamic Data, and is fully usable in ‘regular’ aspx pages. In addition to this preview, you’ll want to also install Microsoft .NET RIA Services in order to get some useful tooling.  This too can be confusing, because it makes it sound like it’s tied to RIA and Silverlight in some way, when in fact it is not. The deal is that there is this new thing called a DomainService, which is essentially a Business Layer class that...
My MIX 2009 ASP.NET Data talk is available online
Last Friday, I gave a talk at MIX on various things that we’re working on in ASP.NET data land.  This includes both some Dynamic Data features and some features usable outside Dynamic Data. The great thing about MIX is that they make all talks freely available online shortly after, and you can watch mine here .  Enjoy! I’ll try to blog in more detail about some of the features discussed in the talk in the next few days. Read More...
Tips on getting your ASP.NET Dynamic Data questions answered quickly
When you run into an issue or have a question about ASP.NET Dynamic Data , the best place for it is the Dynamic Data Forum .  When you write your question, there are a few simple things that you can do to make it easier for the ‘experts’ to answer (and hence to get an answer quicker!). 1. Mention what ORM framework you are using Out of the box, Dynamic Data supports LINQ To SQL and Entity Framework.  While they seem similar on the surface, they are actually fairly different once you get a little deeper into the API.  Just mention which one you’re using and you’ll save a roundtrip. 2. Mention what release you’re using The official release of Dynamic Data is the one that comes with .NET Framework 3.5 SP1 (or Visual Studio 2008 SP1...
A helper to easily set up change notifications in Entity Framework
When you use Entity Framework, you can perform Insert/Update/Delete operations on your entities, and you eventually call ObjectContext.SaveChanges() to actually make it all happen.  The call to SaveChanges() is either explicit, or can happen implicitly when you use the EntityDataSource (e.g. within a Dynamic Data application). Before SaveChanges() actually performs the operations, it gives you a chance to look at the entities, letting you modify them, and possibly cancel certain operations.  Unfortunately, doing this requires using some pretty ugly code, because the API is a little too low level.  Instead of nicely handing you the changes one by one, it just gives you the raw change list and lets you deal with it. For instance...
Two worlds of Dynamic Data customization: generic vs schema specific
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...
Using Dynamic Data with multiple databases
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...
Handling database exceptions in Dynamic Data
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...
Fun with T4 templates and Dynamic Data
T4 templates have been a pretty popular topic lately. If you have no idea what they are, don’t feel bad, I didn’t either only a couple weeks ago! In a nutshell, it’s a simple template processor that’s built into VS and allows for all kind of cool code generation scenario. For a bunch of information about them, check out the following two blogs: GarethJ’s blog Oleg Sych’s blog The basic idea is that you can drop a hello.tt file into a project, and it will generate a hello.cs (or hello.anything) file via its template. The template syntax of .tt files is very similar to ASP.NET’s <% … %> blocks, except that they use <# … #> instead. For a cool example of what you can do with T4, check out this post from Danny Simmons, which shares out...
More Posts Next page »