//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using NHibernate Fluent Mapping template.
// Code is generated on: 21.06.2012 11:42:00
//
// 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 ManyToOne
{
    public class SupplierMap : ClassMap<Supplier>
    {
        public SupplierMap()
        {
              Table("Suppliers");
              LazyLoad();
              Id(x => x.SupplierID)
                .Column("SupplierID")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.CompanyName)    
                .Column("CompanyName")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Not.Nullable()
                .Length(40);
              Component(x => x.Address,
                        aAddress => {
                        aAddress.Access.Property();
                        aAddress.Map(x => x.Address)    
                            .Column("Address")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(60);
                        aAddress.Map(x => x.City)    
                            .Column("City")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(15);
                        aAddress.References(x => x.Country)    
                                    .Class<Country>()
                                    .Access.Property()
                                    .Cascade.None()
                                    .LazyLoad()
                                    .Columns("CountryID");
                        });
        }
    }

    public class OrderMap : ClassMap<Order>
    {
        public OrderMap()
        {
              Table("Orders");
              LazyLoad();
              Id(x => x.OrderID)
                .Column("OrderID")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.Customer)    
                .Column("Customer")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Not.Nullable()
                .Length(50);
              Component(x => x.ShipAddress,
                        aShipAddress => {
                        aShipAddress.Access.Property();
                        aShipAddress.Map(x => x.Address)    
                            .Column("ShipAddress")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(60);
                        aShipAddress.Map(x => x.City)    
                            .Column("ShipCity")
                            .CustomType("String")
                            .Access.Property()
                            .Generated.Never()
                            .CustomSqlType("VARCHAR")
                            .Length(15);
                        aShipAddress.References(x => x.Country)    
                                    .Class<Country>()
                                    .Access.Property()
                                    .Cascade.None()
                                    .LazyLoad()
                                    .Columns("ShipCountryID");
                        });
        }
    }

    public class CountryMap : ClassMap<Country>
    {
        public CountryMap()
        {
              Table("Countries");
              LazyLoad();
              Id(x => x.CountryID)
                .Column("CountryID")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.CountryName)    
                .Column("CountryName")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Not.Nullable()
                .Length(15);
        }
    }

}
