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

January 2009 Entries

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 ......

It turns out the code sample that was posted online for my MVC Visual Studio Magazine article was an older version (based on a previous CTP). The latest version based on the MVC beta can be found here.  Let me know if any problems.


The .NET framework ships with an abstract KeyedCollection<TKey, TItem> class. Basically, all you have to do is implement the GetKeyForItem() method you can could look up any item either by ordinal or a customized key. For example, suppose you had a Person class like this: 1: public class Person 2: { 3: public Guid ID { get; set; } 4: public string FirstName { get; set; } 5: public string LastName { get; set; } 6: } And suppose you wanted to be able to lookup a Person in the collection either ......

Sometimes new features are added to a language which fundamentally change how we do things (e.g., when generics was added to .NET 2.0). However, there are other times when features are added to the language that are “syntax sugar” or “nice to have’s”. My outlook on those items has always been that “syntax sugar” is typically a good thing – if there is some feature that allows the code to be more expressive/readable then that is a great thing. Sure, the IL might not be any different behind the scenes ......