//------------------------------------------------------------------------------
// 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 14:36:08
//
// 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 OneToOne
{
    public class PersonMap : ClassMap<Person>
    {
        public PersonMap()
        {
              Table("Person");
              LazyLoad();
              Id(x => x.PersonID)
                .Column("PersonID")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()
                .GeneratedBy.Assigned();
              Map(x => x.BirthDay)    
                .Column("BirthDay")
                .CustomType("DateTime")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("DATE")
                .Not.Nullable();
              Map(x => x.Address)    
                .Column("Address")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Not.Nullable()
                .Length(200);
              HasOne(x => x.Contact)
                .Class<Contact>()
                .Access.Property()
                .Cascade.None()
                .LazyLoad()
                .Constrained();
        }
    }

    public class ContactMap : ClassMap<Contact>
    {
        public ContactMap()
        {
              Table("Contact");
              LazyLoad();
              Id(x => x.ContactID)
                .Column("ContactID")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.Name)    
                .Column("Name")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Not.Nullable()
                .Length(100);
              Map(x => x.Phone)    
                .Column("Phone")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("СHAR");
              HasOne(x => x.Person)
                .Class<Person>()
                .Access.Property()
                .Cascade.None()
                .LazyLoad();
        }
    }

}
