Databases Reference
In-Depth Information
property so that it returns a collection of UnleashedTableProvider objects instead of the
built-in TableProvider instances. All other properties and methods (thankfully there are
only two) simply call the original implementation. The complete source code of the new
class is shown in Listing 13.8, with important parts highlighted in bold.
LISTING 13.8 UnleashedModelProvider Implementation
namespace Unleashed.DynamicData
{
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Web.DynamicData.ModelProviders;
public sealed class UnleashedModelProvider: DataModelProvider
{
private readonly DataModelProvider original;
private readonly ReadOnlyCollection<TableProvider> tables;
public UnleashedModelProvider(DataModelProvider original)
{
this.original = original;
this.tables = original.Tables
.Select(table => new UnleashedTableProvider(this, table))
.Cast<TableProvider>().ToList().AsReadOnly();
}
public override Type ContextType
{
get { return this.original.ContextType; }
}
public override ReadOnlyCollection<TableProvider> Tables
{
get { return this.tables; }
}
public override object CreateContext()
{
return this.original.CreateContext();
}
}
}
 
Search WWH ::




Custom Search