ASP.NET Podcast

ASP.NET Podcast is geared towards the Microsoft .NET Framework and ASP.NET.
The podcast is run by Wally McClure, David Penton, and Paul Glavich.
Welcome to ASP.NET Podcast Sign in | Join | Help
in Search

ASP.NET Podcast

The ASP.NET Podcast features, technical talks, interviews, news, reviews, and Wallyisms. Wallace B. (Wally) McClure, David Penton, and Paul Glavich are your hosts. We talk about ASP.NET, AJAX, Performance, Databases, WCF, Silverlight, Cloud Computing, Windows Azure, and whatever else we decide to talk about.

ASP.NET Podcast Show #127 - Dynamic Data

Subscribe to All!

Subscribe to WMV.

Subscribe to M4V (iPod).

Subscribe to MP3.

Download WMV.

Download M4V (iPod).

Download MP3.

Show Notes:

Source Code:

Global.asax:

model.RegisterContext(typeof(db35sp1Entities), new ContextConfiguration() { ScaffoldAllTables = true });

Metadata class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Dynamic_Data
{
    [DisplayColumn("Name")]
    [MetadataType(typeof(tbItemMetaData))]
    public partial class tbItem
    {
        private class tbItemMetaData
        {
            [DisplayName("Item Display Name")]
            [StringLength(30)]
            [Required(ErrorMessage="Item name is required.")]
            public object Name { get; set; }

            [DisplayFormat(DataFormatString="{0:c}")]
            [Range(0, 500, ErrorMessage="Standard Cost should be between {1} and {2}.")]
            public object Price { get; set; }
        }

        // Note the naming convention of On X Changing and the nullable value.
        partial void OnPriceChanging(decimal? value)
        {
            if (value < 0)
            {
                throw (new ValidationException("Price must be positive, afterall we aren't paying you to take it."));
            }
        }
    }

    [MetadataType(typeof(tbOrderMetaData))]
    public partial class tbOrder
    {
        private class tbOrderMetaData
        {
            [ScaffoldColumn(true)]
            [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
            public object DateUpdated { get; set; }
        }
    }  
}
 

Published Sunday, November 09, 2008 11:00 PM by admin
Anonymous comments are disabled

This Blog

Syndication

Powered by Community Server, by Telligent Systems