//------------------------------------------------------------------------------
// This is auto-generated code.
//------------------------------------------------------------------------------
// This code was generated by Entity Developer tool using NHibernate Fluent Mapping template.
// Code is generated on: 15.06.2012 12:41:57
//
// 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 Array
{
    public class MessageMap : ClassMap<Message>
    {
        public MessageMap()
        {
              Table("Message");
              LazyLoad();
              Id(x => x.Id)
                .Column("Id")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.Text)    
                .Column("Text")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Length(14);
        }
    }

    public class ConversationMap : ClassMap<Conversation>
    {
        public ConversationMap()
        {
              Table("Conversation");
              LazyLoad();
              Id(x => x.Id)
                .Column("Id")
                .CustomType("Int32")
                .Access.Property()
                .CustomSqlType("INTEGER")
                .Not.Nullable()                
                .GeneratedBy.Identity();
              Map(x => x.Description)    
                .Column("Description")
                .CustomType("String")
                .Access.Property()
                .Generated.Never()
                .CustomSqlType("VARCHAR")
                .Length(40);
              HasMany<Message>(x => x.Messages)
                .Access.Property()
                .AsArray<int>(child => child.Id, map => map.Column("`Order`").Type<int>())
                .Cascade.None()
                // .OptimisticLock.Version() /*bug (or missing feature) in Fluent NHibernate*/
                .KeyColumns.Add("ConversationId", mapping => mapping.Name("ConversationId")
                                                                     .SqlType("INTEGER")
                                                                     .Not.Nullable());
        }
    }

}
