Steve Michelotti

A .NET Developer's Toolbox

  Home  |   Contact  |   Syndication    |   Login
  201 Posts | 0 Stories | 1110 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

Enterprise Library

Lately I’ve been working with EF 4.0 and finding that many of the new features are catching up with the features previously available in other framework like LINQ to SQL. One example of this is the ability to easily attach objects (for example, disconnected objects that come in from another tier). For example, imagine you had a web service where a consumer submitted an object to get saved – you’d want to instantiate a new context, attach the incoming entity, and save the object. In previous versions ......

Thanks to everyone who attended my presentation last night at FredNUG.  The code samples can be downloaded here.

A while back, I blogged about using the Enterprise Library Validation Application Block (VAB) with ASP.NET MVC. As MVC has matured as a framework, this scenario has becoming simpler. In early releases of MVC, I implemented the execution of the VAB validation in the controller methods. However, I now prefer to put that logic in the binders themselves. In earlier versions of the framework, the model binders that came out of the box dealt well with simple objects but if you had more complex View Models ......

The Enterprise Library Validation Application Block (VAB) is a great library for putting your validation in your business layer where it belongs rather than in the UI. It allows us to apply attributes to the properties of our business objects like this: 1: public class Person 2: { 3: [StringLengthValidator(1, 20, MessageTemplate="First Name must be between 1-20 characters.")] 4: public string FirstName { get; set; } 5: 6: [StringLengthValidator(1, 20, MessageTemplate="Last Name must be between 1-20 ......

Several weeks ago (before the release of the CTP5 of MVC) I posted a way to leverage the EntLib Validation Application Block with MVC. Since then CTP5 has been released and this finally includes a mechanism for reporting validations. It is important to note that it does not include the mechanism for *how* to do validation but rather how to *report* validations. This is actually a great thing because, first off, it allows the flexibility to utilize whatever validation framework you please rather than ......

UPDATE: This post is now out of date as of the CTP5 release of the MVC framework. For the lastest version, see this post here. One of the areas of MVC that is still an open area in development is how best to handle UI validations. There are numerous approaches currently being examined. MVCContrib Validator Toolkit for MVC The Enterprise Library's VAB is great because it allows you to specify all your validation logic in your business layer where it belongs rather than in your UI. Additionally, it ......

The Enterprise Library VAB provides the PropertyProxyValidator for ASP.NET applications so that you can attach it to a single control and it will display any validation messages for that business object property. This automatic UI validation is great because it avoids duplicating your business layer validation logic in your UI. Additionally, you can just use ONE validator control whereas using traditional ASP.NET validation controls you might need to attach 3-4 validation controls to a single UI ......

In a previous post I discussed validating strings with the VAB in the context of ASP.NET applications. In summary, you must have a NotNullValidator and also a StringLengthValidator that prevents a string length of zero on the lower bound and prevents a string length above your upper bound (e.g., 50 characters). That attribute might look like this: 1: [StringLengthValidator(1, 50, MessageTemplate="First Name must be 1-50 characters.")] But the problem is that the StringLengthValidator is really doing ......

You've created a class like this and all your unit tests pass just fine when you check for null strings or strings greater than 50 characters: 1: public class Person 2: { 3: [NotNullValidator(MessageTe... Name is required.")] 4: [StringLengthValidator(50, MessageTemplate="First Name must be 1-50 characters.")] 5: public string FirstName { get; set; } 6: } But then when you run it in an ASP.NET application with the PropertyProxyValidator validation control provided by VAB, your business ......