static void

ActiveRecord

As a comparison to the hbm mapping files, here's the Category and Product entities marked up for ActiveRecord. See the App.Config

Category

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Castle.ActiveRecord;
 
namespace NorthwindActive
{
   /// <summary>
   /// Class representing Categories table
   /// </summary>
   [Serializable]
   [ActiveRecord("`Categories`", Lazy = true)]
   public class Category : ActiveRecordBase<Category>
   {
 
      #region Fields
      [DebuggerBrowsable(DebuggerBrowsableState.Never)]
      private IList<Product> _productCollection = new List<Product>();
      #endregion
 
      #region Properties
      /// <summary>
      /// CategoryID (Key)
      /// </summary>
      [PrimaryKey("`CategoryID`")]
      public virtual int CategoryId { get; set; }
      /// <summary>
      /// CategoryName (Required)
      /// </summary>
      [Property("`CategoryName`")]
      public virtual string CategoryName { get; set; }
      /// <summary>
      /// Description
      /// </summary>
      [Property("`Description`", ColumnType="StringClob")]
      public virtual string Description { get; set; }
      /// <summary>
      /// Picture
      /// </summary>
      [Property("`Picture`")]
      public virtual System.Byte[] Picture { get; set; }
      /// <summary>
      /// Foreign Key Collection
      /// </summary>
      [HasMany(typeof(Product), "CategoryId", "`Products`" , Lazy = true, Inverse = true, Cascade = ManyRelationCascadeEnum.AllDeleteOrphan, Access=PropertyAccess.NosetterCamelcaseUnderscore)]
      public virtual IList<Product> ProductCollection
      {
            get
            {
               return _productCollection;
            }
      }
      #endregion
 
      #region overrides
      public override string ToString()
      {
         return "Category = " + CategoryId;
      }
 
      public override int GetHashCode()
      {
         if (CategoryId == 0) return base.GetHashCode();
         return CategoryId;
      }
 
      public override bool Equals(object obj)
      {
         Category x = obj as Category;
         if (x == null) return false;
         if (CategoryId == 0 && x.CategoryId == 0) return object.ReferenceEquals(this, x);
         return (CategoryId == x.CategoryId);
      }
      #endregion
   } //class
} //namespace

Product

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Castle.ActiveRecord;
 
namespace NorthwindActive
{
   /// <summary>
   /// Class representing Products table
   /// </summary>
   [Serializable]
   [ActiveRecord("`Products`", Lazy = true)]
   public class Product : ActiveRecordBase<Product>
   {
 
      #region Properties
      /// <summary>
      /// ProductID (Key)
      /// </summary>
      [PrimaryKey("`ProductID`")]
      public virtual int ProductId { get; set; }
      /// <summary>
      /// ProductName (Required)
      /// </summary>
      [Property("`ProductName`")]
      public virtual string ProductName { get; set; }
      ///// <summary>
      ///// Foreign Key Entity for SupplierId (Optional)
      ///// </summary>
      //[BelongsTo("`SupplierID`")]
      //public virtual Supplier Supplier { get; set; }
      /// <summary>
      /// Foreign Key Entity for CategoryId (Optional)
      /// </summary>
      [BelongsTo("`CategoryID`")]
      public virtual Category Category { get; set; }
      /// <summary>
      /// QuantityPerUnit
      /// </summary>
      [Property("`QuantityPerUnit`")]
      public virtual string QuantityPerUnit { get; set; }
      /// <summary>
      /// UnitPrice
      /// </summary>
      [Property("`UnitPrice`")]
      public virtual decimal? UnitPrice { get; set; }
      /// <summary>
      /// UnitsInStock
      /// </summary>
      [Property("`UnitsInStock`")]
      public virtual short? UnitsInStock { get; set; }
      /// <summary>
      /// UnitsOnOrder
      /// </summary>
      [Property("`UnitsOnOrder`")]
      public virtual short? UnitsOnOrder { get; set; }
      /// <summary>
      /// ReorderLevel
      /// </summary>
      [Property("`ReorderLevel`")]
      public virtual short? ReorderLevel { get; set; }
      /// <summary>
      /// Discontinued (Required)
      /// </summary>
      [Property("`Discontinued`")]
      public virtual bool Discontinued { get; set; }
       #endregion
 
      #region overrides
      public override string ToString()
      {
         return "Product = " + ProductId;
      }
 
      public override int GetHashCode()
      {
         if (ProductId == 0) return base.GetHashCode();
         return ProductId;
      }
 
      public override bool Equals(object obj)
      {
         Product x = obj as Product;
         if (x == null) return false;
         if (ProductId == 0 && x.ProductId == 0) return object.ReferenceEquals(this, x);
         return (ProductId == x.ProductId);
      }
      #endregion
   } //class
} //namespace