using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord.Framework;
using Castle.ActiveRecord.Framework.Config;
using Castle.ActiveRecord;
using System.Reflection;

namespace ManyToManyExample
{
    class Program
    {
        static void Main( string[] args )
        {
            IConfigurationSource source = ActiveRecordSectionHandler.Instance;
            ActiveRecordStarter.Initialize( Assembly.GetAssembly( typeof( Program ) ), source );
            ActiveRecordStarter.DropSchema();
            ActiveRecordStarter.CreateSchema();

            var kat1 = new Kategoria { Nazwa = "Powieść" };
            var kat2 = new Kategoria { Nazwa = "SF" };
            var ks1 = new Ksiazka { Tytul = "Harry Potter" };
            var ks2 = new Ksiazka { Tytul = "Kongres futurologiczny" };
            var ks3 = new Ksiazka { Tytul = "Mistrz i Małgorzata" };
            ks1.L_Kategoria.Add( kat1 );
            ks1.L_Kategoria.Add( kat2 );
            ks2.L_Kategoria.Add( kat2 );
            ks3.L_Kategoria.Add( kat1 );
//            kat1.Save(); kat2.Save();
            ks1.Save(); ks2.Save(); ks3.Save();
        }
    }
}
