//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using NHibernate Fluent Mapping template.
// Code is generated on: 18.06.2012 13:09:16
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using FluentNHibernate.Mapping;
using FluentNHibernate.MappingModel.Collections;

namespace CollectionsOfComponents
{
    public class DepartmentMap : ClassMap<Department>
    {
        public DepartmentMap()
        {
              Table("Department");
              LazyLoad();
              Id(x => x.DepartmentId)
                .Column("DepartmentId")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.Name)    
                .Column("Name")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Length(14);
              HasMany<EmployeeType>(x => x.Employees)
                .Access.Property()
                .AsSet()
                .Component(c => {
                        c.Map(x => x.Name)    
                            .Column("Name")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(10);
                        c.Map(x => x.Job)    
                            .Column("Job")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(9);
                        })
                .Table("Employee")
                .Cascade.None()
                .LazyLoad()
                .Generic()
                .KeyColumns.Add("DepartmentId", mapping => mapping.Name("DepartmentId")
                                                                     .SqlType("INTEGER")
                                                                     .Not.Nullable());
        }
    }

}
