Language preference:

Phase 2 / ScaffoldColumnAttribute and ScaffoldTableAttribute

When you view the BLD application in Phase 1, it lists all of the Entity classes and many DataFields. The BLD user interface gathers these lists from the business logic using Automatic Scaffolding. Without doing anything, you will get DataFields in the order they appear in the Entity class. It will only skip certain DataFields based on their type and a few other characteristics.

Note Automatic Scaffolding is not required for a BLD application. As you work through this guided tour, you will learn how to explicitly define which DataFields appear.

Use the DESDA.ScaffoldColumnAttribute to override these rules. It determines if the DataField is shown, based on the data entry mode, and its order. (Data entry modes are read-only, edit, and insert.)

Use the ScaffoldTableAttribute (notice it doesn't use "DESDA.") to exclude Entity classes that you do not want in a list of available Entities.

Note Microsoft includes System.ComponentModel.DataAnnotations.ScaffoldColumnAttribute from which BLD's is subclassed. It is supported by BLD, as is the Scaffold property found on the System.ComponentModel.DataAnnotations.DisplayAttribute. However, these lack the ordering and ability to show or hide based on the data entry mode.

Here are DESDA.ScaffoldColumnAttributes associated with the Order Entity class and the ScaffoldTableAttribute which hides the Order_Details Entity class.

public class OrderMetadata
   [DESDA.ScaffoldColumn(ScaffoldEdit = false, ScaffoldInsert = false)]
   public object CustomerID { get; set; }

   [DESDA.ScaffoldColumn(Position = 0)]  // make it appear first
   public object Customer { get; set;  }
public class Order_DetailMetadata

The Source Code Browser shows completed DataAnnotations. The DESDA.ScaffoldColumnAttributes and ScaffoldTableAttributes have been highlighted.

In the next topic, you'll learn how to restrict access to Entities and specific DataFields based on the user's role.

Open the Source Code Browser (C# only)
Source Code Browser
/* ------------------------------------------------
 * Describes the Entity class for: CustomerCustomerDemo
 * Classes:
 *    CustomerCustomerDemo - Entity class. Edit it for validation and to customize metadata at runtime
 *    CustomerCustomerDemoMetadata - Entity Metadata class. It contains the DataAnnotations.
 *    CustomerCustomerDemoDAO - BLD DataAccessObject format version of a Data Access Object.
 * Requires .net 4.0 and these references:
 *    System.ComponentModel.DataAnnotations
 *    PeterBlum.DES
 *    PeterBlum.DES.DataAnnotations
 * Generated: 7/8/2011 4:35:39 PM
 * ------------------------------------------------*/
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using PeterBlum.DES.DAO.Attributes;
using PeterBlum.DES.DAO.EntityDAO;
// Some members of this namespace have identical names to those in System.ComponentModel.DataAnnotations
// making it easy to switch from one to the other by adding the "DESDA." prefix
using DESDA = PeterBlum.DES.DataAnnotations;

namespace PeterBlum.WithDataAnnotations
   // --- ENTITY CLASS --------------------------------------------------
   /// <summary>
   /// Entity class. Edit it for validation and to customize metadata at runtime
   /// </summary>
   public partial class CustomerCustomerDemo
   }  // class CustomerCustomerDemo

   // --- ENTITY METADATA --------------------------------------------------
   /// <summary>
   /// Entity Metadata class.
   /// Companion to the CustomerCustomerDemo Entity class that contains the DataAnnotations
   /// on properties with the same names as those in the actual Entity class.
   /// These properties do not require their types to match those in the Entity class.
   /// An Entity Metadata class allows the Entity class to be regenerated without
   /// overwriting DataAnnotations.
   /// </summary>
   [DESDA.DisplayName("Customer to Customer Demographics")]
   [DESDA.TableRestriction("Admin", DESDA.DenyAccess.None)]
   [DESDA.TableRestriction("Customer", DESDA.DenyAccess.All)]
   public class CustomerCustomerDemoMetadata

   }  // class CustomerCustomerDemoMetadata
   // --- BLD DATAACCESSOBJECT  --------------------------------------------------
   /// <summary>
   /// BLD DataAccessObject class for the CustomerCustomerDemo Entity class.
   /// It provides CRUD actions. The parent class already has default
   /// methods for Update(), Insert(), Delete() and several queries.
   /// </summary>
   /// <remarks>
   /// <para>For documentation, see the BLD DataAccessObject section of the Business Logic User's Guide.</para>
   /// </remarks>
   public class CustomerCustomerDemoDAO : LINQtoSQLEntityDAO<CustomerCustomerDemo>
      public CustomerCustomerDemoDAO() : base(typeof(NorthWindDataContext)) { }
      public CustomerCustomerDemoDAO(object pDataContext) : base(pDataContext) { }

   }  // class CustomerCustomerDemoDAO