I've created a patch adding support for mapping entities in multiple
assemblies. It basically follows the logic I suggested in the posts
above. I've added a test verifying it works and as well as updated 3
tests that were failing as a result (I think) of a recent change in
the mappings pushing column declarations in the xml from attributes to
elements. I just updated the XPATH query to point to the "column"
element and set the HasAttribute to look for the "name" attribute for
all three tests. They are (in the AutoPersistenceModelTests class):
MapsPropertyWithPropertyConvention,
ComponentColumnConventionReceivesProperty and
ComponentPropertiesAssumeComponentColumnPrefix. You might want to
confirm that that is the expected behaviour.

In order to create the test for mapping entities from multiple
assemblies I added a reference to Examples.FirstProject to the test
project.

Here's the patch. I apologize in advance if this isn't the accepted
way to submit patches. Just let me know how it's normally done and
I'll do so henceforth.:

Index: src/FluentNHibernate.Testing/AutoMap/
AutoPersistenceModelTests.cs
===================================================================
--- src/FluentNHibernate.Testing/AutoMap/AutoPersistenceModelTests.cs
(revision 0)
+++ src/FluentNHibernate.Testing/AutoMap/AutoPersistenceModelTests.cs
(revision 0)
@@ -0,0 +1,477 @@
+using System;
+using System.Diagnostics;
+using FluentNHibernate.AutoMap;
+using FluentNHibernate.AutoMap.TestFixtures.ComponentTypes;
+using FluentNHibernate.AutoMap.TestFixtures.CustomTypes;
+using NUnit.Framework;
+using SuperTypes = FluentNHibernate.AutoMap.TestFixtures.SuperTypes;
+using FluentNHibernate.AutoMap.TestFixtures;
+
+namespace FluentNHibernate.Testing.AutoMap
+{
+    using Examples.FirstProject.Entities;
+    using Fixtures.EntitiesInMultipleAssemblies;
+
+    [TestFixture]
+    public class AutoPersistenceModelTests : BaseAutoPersistenceTests
+    {
+        [Test]
+        public void MapsPropertyWithPropertyConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleCustomColumn>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(convention =>
+                {
+                    convention.AddPropertyConvention(new
XXAppenderPropertyConvention());
+                });
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/proper...@name='LineOne']/
column").HasAttribute("name", "LineOneXX");
+        }
+
+        [Test]
+        public void TestAutoMapsIds()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleCustomColumn>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/id").Exists();
+        }
+
+        [Test]
+        public void TestAutoMapsProperties()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("//property").HasAttribute("name",
"ExampleClassId");
+        }
+
+        [Test]
+        public void TestAutoMapIgnoresProperties()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .ForTypesThatDeriveFrom<ExampleCustomColumn>(c =>
c.IgnoreProperty(p => p.ExampleCustomColumnId));
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleCustomColumn>(autoMapper)
+                .Element("//property").DoesntExist();
+        }
+
+        [Test]
+        public void TestAutoMapManyToOne()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("//many-to-one").HasAttribute("name",
"Parent");
+        }
+
+        [Test]
+        public void TestAutoMapOneToMany()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleParentClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleParentClass>(autoMapper)
+                .Element("//bag")
+                .HasAttribute("name", "Examples");
+        }
+
+        [Test]
+        public void TestAutoMapPropertyMergeOverridesId()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .ForTypesThatDeriveFrom<ExampleClass>(map => map.Id(c
=> c.Id, "Column"));
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/id")
+                .HasAttribute("name", "Id")
+                .HasAttribute("column", "Column");
+        }
+
+        [Test]
+        public void TestAutoMapPropertySetPrimaryKeyConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(c=> c.GetPrimaryKeyName = p=> p.Name
+ "Id");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/id")
+                .HasAttribute("name", "Id")
+                .HasAttribute("column", "IdId");
+        }
+
+        [Test]
+        public void TestAutoMapIdUsesConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<PrivateIdSetterClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(convention =>
+                    convention.IdConvention = id =>
id.Access.AsLowerCaseField());
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<PrivateIdSetterClass>(autoMapper)
+                .Element("class/id")
+                .HasAttribute("access", "field.lowercase");
+        }
+
+        [Test]
+        public void TestAutoMapPropertySetManyToOneKeyConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(c =>
+                                    {
+                                        c.GetForeignKeyName = p =>
p.Name + "Id";
+                                    });
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("//many-to-one")
+                .HasAttribute("name", "Parent")
+                .HasAttribute("column", "ParentId");
+        }
+
+        [Test]
+        public void TestAutoMapPropertySetOneToManyKeyConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(c => c.GetForeignKeyNameOfParent =  t
=> t.Name + "Id");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleParentClass>(autoMapper)
+                .Element("//bag")
+                .HasAttribute("name", "Examples")
+                .Element("//key")
+                .HasAttribute("column", "ExampleParentClassId");
+        }
+
+        [Test]
+        public void TestAutoMapPropertySetFindPrimaryKeyConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t == typeof(ExampleClass))
+                .WithConvention(c => c.FindIdentity = p => p.Name ==
p.DeclaringType.Name + "Id" );
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/id")
+                .HasAttribute("name", "ExampleClassId")
+                .HasAttribute("column", "ExampleClassId");
+        }
+
+        [Test]
+        [ExpectedException(typeof(NullReferenceException))]
+        public void TestInheritanceMappingSkipsSuperTypes()
+        {
+            var autoMapper = AutoPersistenceModel
+                    .MapEntitiesFromAssemblyOf<ExampleClass>()
+                    .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures.SuperTypes")
+                    .WithConvention(c =>
+                                        {
+                                            c.IsBaseType = b => b ==
typeof(SuperTypes.SuperType);
+                                        });
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<SuperTypes.SuperType>(autoMapper);
+        }
+
+        [Test]
+        public void TestInheritanceMapping()
+        {
+            var autoMapper = AutoPersistenceModel
+                    .MapEntitiesFromAssemblyOf<ExampleClass>()
+                    .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            var tester = new AutoMappingTester<ExampleClass>
(autoMapper)
+                .Element("class/joined-subclass")
+                .HasAttribute("name", typeof
(ExampleInheritedClass).AssemblyQualifiedName);
+
+            tester.Element("class/joined-subclass/key")
+                .HasAttribute("column", "ExampleClassId");
+        }
+
+        [Test]
+        public void TestInheritanceMappingProperties()
+        {
+            var autoMapper = AutoPersistenceModel
+                    .MapEntitiesFromAssemblyOf<ExampleClass>()
+                    .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            var tester = new AutoMappingTester<ExampleClass>
(autoMapper)
+                .Element("class/joined-subclass/property")
+                .HasAttribute("name", "ExampleProperty");
+        }
+
+        [Test]
+        public void
TestInheritanceMappingDoesntIncludeBaseTypeProperties()
+        {
+            var autoMapper = AutoPersistenceModel
+                    .MapEntitiesFromAssemblyOf<ExampleClass>()
+                    .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("class/joined-subclass")
+                .ChildrenDontContainAttribute("name", "LineOne");
+        }
+
+        [Test]
+        public void TestInheritanceOverridingMappingProperties()
+        {
+            var autoMapper = AutoPersistenceModel
+                    .MapEntitiesFromAssemblyOf<ExampleClass>()
+                    .ForTypesThatDeriveFrom<ExampleClass>(t =>
t.JoinedSubClass<ExampleInheritedClass>("OverridenKey", p  => p.Map(c
=> c.ExampleProperty, "columnName")))
+                    .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper).ToString
();
+
+            var tester = new AutoMappingTester<ExampleClass>
(autoMapper)
+                .Element("class/joined-subclass")
+                .ChildrenDontContainAttribute("name", "LineOne");
+        }
+
+        [Test]
+        public void TestMappingEntitiesFromMultipleAssemblies()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<SalesPerson>()
+                .IncludeEntitiesFromAssemblyOf<Employee>()
+                .Where(
+                t =>
+                t.Namespace ==
"FluentNHibernate.Testing.Fixtures.EntitiesInMultipleAssemblies" ||
+                t.Namespace == "Examples.FirstProject.Entities");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Employee>(autoMapper)
+                .Element("class/joined-subclass/property")
+                .HasAttribute("name", "TotalSales");
+        }
+
+        [Test]
+        public void TestAutoMapClassSetCacheConvention()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(c => c.DefaultCache = cache =>
cache.AsReadWrite());
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ExampleClass>(autoMapper)
+                .Element("//cache").HasAttribute("usage", "read-
write");
+        }
+
+        [Test]
+        public void CanSearchForOpenGenericTypes()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.CompileMappings();
+            autoMapper.FindMapping(typeof(SomeOpenGenericType<>));
+        }
+
+        [Test]
+        public void TypeConventionShouldForcePropertyToBeMapped()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ClassWithUserType>()
+                .WithConvention(convention =>
+                {
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<ClassWithUserType>(autoMapper)
+                .Element("class/property").HasAttribute("name",
"Custom");
+        }
+
+        [Test]
+        public void ComponentTypesAutoMapped()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<Customer>()
+                .WithConvention(convention =>
+                {
+                    convention.IsComponentType =
+                        type => type == typeof(Address);
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Customer>(autoMapper)
+                .Element("class/component
[...@name='HomeAddress']").Exists()
+                .Element("class/component
[...@name='WorkAddress']").Exists();
+        }
+
+        [Test]
+        public void ComponentPropertiesAutoMapped()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<Customer>()
+                .WithConvention(convention =>
+                {
+                    convention.IsComponentType =
+                        type => type == typeof(Address);
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Customer>(autoMapper)
+                .Element("class/component/property
[...@name='Number']").Exists()
+                .Element("class/component/property
[...@name='Street']").Exists();
+        }
+
+        [Test]
+        public void ComponentPropertiesWithUserTypeAutoMapped()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<Customer>()
+                .WithConvention(convention =>
+                {
+                    convention.IsComponentType =
+                        type => type == typeof(Address);
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Customer>(autoMapper)
+                .Element("class/component/property
[...@name='Custom']").HasAttribute("type", typeof
(CustomUserType).AssemblyQualifiedName);
+        }
+
+        [Test]
+        public void ComponentPropertiesAssumeComponentColumnPrefix()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<Customer>()
+                .WithConvention(convention =>
+                {
+                    convention.IsComponentType =
+                        type => type == typeof(Address);
+                    convention.GetComponentColumnPrefix =
+                        property => property.Name + "_";
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Customer>(autoMapper)
+                .Element("class/compone...@name='WorkAddress']/
proper...@name='Number']/column").HasAttribute("name",
"WorkAddress_Number");
+        }
+
+        [Test]
+        public void ComponentColumnConventionReceivesProperty()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<Customer>()
+                .WithConvention(convention =>
+                {
+                    convention.IsComponentType =
+                        type => type == typeof(Address);
+                    convention.GetComponentColumnPrefix =
+                        property => property.Name + "_";
+                    convention.AddTypeConvention(new
CustomTypeConvention());
+                })
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures");
+
+            autoMapper.Configure(cfg);
+
+            new AutoMappingTester<Customer>(autoMapper)
+                .Element("class/compone...@name='WorkAddress']/
proper...@name='Number']/column")
+                .HasAttribute("name", value => value.StartsWith
("WorkAddress_"));
+        }
+
+        [Test]
+        public void
ForTypesThatDeriveFromTThrowsExceptionIfCalledMoreThanOnceForSameType
()
+        {
+            var ex = Assert.Throws<AutoMappingException>(() =>
AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ExampleClass>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .ForTypesThatDeriveFrom<ExampleClass>(map => { })
+                .ForTypesThatDeriveFrom<ExampleClass>(map => { }));
+
+            Assert.That(ex.Message, Is.EqualTo
("ForTypesThatDeriveFrom<T> called more than once for 'ExampleClass'.
Merge your calls into one."));
+        }
+
+        [Test]
+        public void IdIsMappedFromGenericBaseClass()
+        {
+            var autoMapper = AutoPersistenceModel
+                .MapEntitiesFromAssemblyOf<ClassUsingGenericBase>()
+                .Where(t => t.Namespace ==
"FluentNHibernate.AutoMap.TestFixtures")
+                .WithConvention(convention =>
+                {
+                    convention.IsBaseType =
+                        type => type == typeof(object) || type ==
typeof(EntityBase<>);
+                });
+
+           autoMapper.Configure(cfg);
+
+           new AutoMappingTester<ClassUsingGenericBase>(autoMapper)
+               .Element("class/id")
+               .HasAttribute("name", "Id");
+        }
+    }
+
+    public class SomeOpenGenericType<T>
+    {}
+}
\ No newline at end of file
Index: src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
===================================================================
--- src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
(revision 322)
+++ src/FluentNHibernate.Testing/FluentNHibernate.Testing.csproj
(working copy)
@@ -3,7 +3,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</
Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{F5DC3221-827E-4CB4-B61C-5F50EB4D32EA}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -78,6 +78,7 @@
     <Compile Include="AutoMap\AutoMappingTester.cs" />
     <Compile Include="AutoMap\AutoMapTests.cs" />
     <Compile Include="AutoMap\Apm\AutoPersistenceModelTests.cs" />
+    <Compile Include="AutoMap\AutoPersistenceModelTests.cs" />
     <Compile Include="AutoMap\BaseAutoPersistenceTests.cs" />
     <Compile Include="AutoMap\ManyToMany.cs" />
     <Compile Include="AutoMap\ManyToManyAutomapperTester.cs" />
@@ -91,6 +92,7 @@
     <Compile Include="Fixtures\AutoMappingAlterations
\DummyAlteration2.cs" />
     <Compile Include="Fixtures\AutoMappingAlterations
\DummyOverride.cs" />
     <Compile Include="Fixtures\AutoMappingAlterations\Model\Baz.cs" /
>
+    <Compile Include="Fixtures\EntitiesInMultipleAssemblies
\SalesPerson.cs" />
     <Compile Include="Fixtures\MixedMappingsInSameLocation\Bar.cs" />
     <Compile Include="Fixtures\MixedMappingsInSameLocation\Foo.cs" />
     <Compile Include="Fixtures\MixedMappingsInSameLocation\Mappings
\FooMap.cs" />
@@ -158,6 +160,10 @@
     <Compile Include="TestUtility.cs" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\Examples.FirstProject
\Examples.FirstProject.csproj">
+      <Project>{B43FC076-1704-409A-A4F5-91A5DB22B4CF}</Project>
+      <Name>Examples.FirstProject</Name>
+    </ProjectReference>
     <ProjectReference Include="..\FluentNHibernate
\FluentNHibernate.csproj">
       <Project>{1C988DFB-1EC5-484E-87D9-1D3C775BA435}</Project>
       <Name>FluentNHibernate</Name>
Index: src/FluentNHibernate/AutoMap/AutoPersistenceModel.cs
===================================================================
--- src/FluentNHibernate/AutoMap/AutoPersistenceModel.cs        (revision
322)
+++ src/FluentNHibernate/AutoMap/AutoPersistenceModel.cs        (working
copy)
@@ -7,11 +7,14 @@

 namespace FluentNHibernate.AutoMap
 {
+    using System.Linq;
+    using Iesi.Collections.Generic;
+
     public class AutoPersistenceModel : PersistenceModel
     {
         private readonly AutoMapper autoMapper;
         private Assembly assemblyContainingMaps;
-        private Assembly entityAssembly;
+        private readonly ISet<Assembly> entityAssemblies = new
HashedSet<Assembly>();
         private Func<Type, bool> shouldIncludeType;
         private readonly List<AutoMapType> mappingTypes = new
List<AutoMapType>();
         private bool autoMappingsCreated;
@@ -58,6 +61,12 @@
             return persistenceModel;
         }

+        public AutoPersistenceModel IncludeEntitiesFromAssemblyOf<T>
()
+        {
+            this.AddEntityAssembly(Assembly.GetAssembly(typeof (T)));
+            return this;
+        }
+
         public AutoPersistenceModel Where(Func<Type, bool>
shouldIncludeType)
         {
             this.shouldIncludeType = shouldIncludeType;
@@ -77,36 +86,24 @@

             alterations.Apply(this);

-            foreach (var type in entityAssembly.GetTypes())
-            {
-                if (shouldIncludeType != null)
-                {
-                    if (!shouldIncludeType.Invoke(type))
-                        continue;
-                }
+            (from asm in entityAssemblies
+             from type in asm.GetTypes()
+             where (shouldIncludeType != null ? shouldIncludeType
(type) : true) &&
+                   !(Conventions.IsBaseType(type) || type == typeof
(object) || type.IsAbstract)
+             select type).ForEach(type => mappingTypes.Add(new
AutoMapType(type)));

-                if (Conventions.IsBaseType(type) || type == typeof
(object) || type.IsAbstract)
-                    continue;
+            mappingTypes.ForEach(type =>
+                                     {
+                                         if (!type.Type.IsClass || !
isnotAnonymousMethodClass(type)) return;
+                                         if (type.IsMapped) return;
+                                         var mapping = FindMapping
(type.Type);

-                mappingTypes.Add(new AutoMapType(type));
-            }
+                                         if (mapping != null)
+                                             MergeMap(type.Type,
mapping);
+                                         else
+                                             AddMapping(type.Type);
+                                     });

-            foreach (var type in mappingTypes)
-            {
-                if (type.Type.IsClass && isnotAnonymousMethodClass
(type))
-                {
-                    if (!type.IsMapped)
-                    {
-                        var mapping = FindMapping(type.Type);
-
-                        if (mapping != null)
-                            MergeMap(type.Type, mapping);
-                        else
-                            AddMapping(type.Type);
-                    }
-                }
-            }
-
             autoMappingsCreated = true;
         }

@@ -212,7 +209,7 @@

         public AutoPersistenceModel AddEntityAssembly(Assembly
assembly)
         {
-            entityAssembly = assembly;
+            entityAssemblies.Add(assembly);
             return this;
         }

Index: src/FluentNHibernate/Extensions.cs
===================================================================
--- src/FluentNHibernate/Extensions.cs  (revision 322)
+++ src/FluentNHibernate/Extensions.cs  (working copy)
@@ -7,6 +7,8 @@

 namespace FluentNHibernate
 {
+    using System.Collections.Generic;
+
     public static class ConfigurationHelper
     {
         public static Configuration AddMappingsFromAssembly(this
Configuration configuration, Assembly assembly)
@@ -43,4 +45,16 @@
             return constructor.Invoke(null);
         }
     }
+
+    public static class EnumerableExtensions
+    {
+        public static void ForEach<T>(this IEnumerable<T>
sequence,Action<T> action)
+        {
+            if (action == null) throw new ArgumentNullException
("action");
+            foreach(var item in sequence)
+            {
+                action.Invoke(item);
+            }
+        }
+    }
 }
\ No newline at end of file


On Feb 17, 4:38 pm, Jimit <jimitndi...@gmail.com> wrote:
> The base classPersistenceModel already has a method AddEntityAssembly
> (Assembly assembly) seeming to suggest the semantics of working with
> multiple entity assemblies is already part of the API. I'd think it
> would simply be a matter of fitting the call into the fluent api for
> APMs, though there could be other ramifications that I'm missing?
>
> On Feb 17, 4:30 pm, Jimit <jimitndi...@gmail.com> wrote:
>
> > Any word on support formappingentities from multiple assemblies? I'd
> > also appreciate feedback on the proposed solution above.
>
> > On Feb 12, 11:40 pm, Jimit <jimitndi...@gmail.com> wrote:
>
> > > Maybe we need a instance method on AutoPersistenceModel a la
> > > IncludeEntitiesFromAssembly<T> so we could say:
>
> > > var model =
> > > AutoPersistenceModel.MapEntitiesFromAssembly<T>.IncludeEntitiesFromAssembly
> > >  <T>
> > > (... and so on).Where(GetEntityFilter)...
> > > The first call to MapEntitiesFromAssembly<T> would do essentially what
> > > it does now except that it'd save the assembly to an
> > > ICollection<Assembly>. Subsequent calls to
> > > IncludeEntitesFromAssembly<T> would add additional assemblies to that
> > > collection (it'd be prudent to make sure the same assembly isn't added
> > > twice).
> > > Everything from that point on would be business as usual till it came
> > > to CompileMappings in which case we could do something like..
>
> > > var entitiesToMap = mappingAssemblies.SelectMany(asm =>
> > > asm.GetExportedTypes()).Where(t => shouldInclude(t) && !
> > > Conventions.IsBaseType(t));
> > > entitiesToMap.ForEach(entity => {varmapping= FindMapping(entity); if
> > > (mapping!= null) MergeMapping(mapping) else AddMapping(mapping)
>
> > > (excuse the typos and syntax errors - running on mental compiler
> > > again :-) )
>
> > > The Where clause above would need to identify entities from all
> > > included assemblies
> > > What do you think?
>
> > > On Feb 12, 6:01 pm, James Gregory <jagregory....@gmail.com> wrote:
>
> > > > MapEntitiesFromAssembly<T> creates an instance of an 
> > > > AutoPersistenceModel,
> > > > so you'd need to do something like this to use multiple assemblies:
> > > > var autoMapper1 = AutoPersistenceModel.MapEntitiesFromAssembly<A>();
> > > > var autoMapper2 = AutoPersistenceModel.MapEntitiesFromAssembly<B>();
>
> > > > The problem is, that would only map two separate class hierarchies, and 
> > > > not
> > > > handle any mixing of the two. I don't think it's currently possible to 
> > > > map
> > > > two assemblies as one logical domain. This is something that we should
> > > > support though.On Thu, Feb 12, 2009 at 5:20 PM, Jimit 
> > > > <jimitndi...@gmail.com> wrote:
>
> > > > > That unfortunately raises other issues for me - all my base classes
> > > > > including DomainObject are in another assembly (Core.Common) than the
> > > > > one that holds my domain model (Core.Domain). I don't suppose it's
> > > > > possible to call MapEntitiesFromAssembly<T> more than once and filter
> > > > > it with the same predicate in the Where method? I seem to remember
> > > > > MapEntitiesFromAssembly<T> simply saving a reference to the assembly
> > > > > for use later in CompileMappings which would mean that calling it
> > > > > twice would simply reset the reference.
> > > > > What do you think?
>
> > > > > On Feb 12, 8:54 am, James Gregory <jagregory....@gmail.com> wrote:
> > > > > > Yeah, that makes sense. Currently you shouldn't exclude something 
> > > > > > set
> > > > > with
> > > > > > IsBaseType in your Where clause. That being said, the two should 
> > > > > > probably
> > > > > > be equivalent really.
>
> > > > > > On Thu, Feb 12, 2009 at 6:10 AM, Jimit <jimitndi...@gmail.com> 
> > > > > > wrote:
>
> > > > > > > I think I may have found the problem. DomainObject was excluded 
> > > > > > > by my
> > > > > > > entity filter in my call to Where on the AutoPersistenceModel 
> > > > > > > (since
> > > > > > > it itself is not an entity, just a common base class for both 
> > > > > > > entities
> > > > > > > and value objects and thus it doesn't have an Id, I figured no 
> > > > > > > need).
> > > > > > > I subsequently did amappingoverride using
> > > > > > > ForTypesThatDeriveFrom<DomainObject> which internally populates an
> > > > > > > AutoMap<DomainObject>. In CompileMappings however the conditions 
> > > > > > > that
> > > > > > > would normally exclude DomainObject from the finalmapping(i.e the
> > > > > > > checks for shouldInclude and IsBaseType) don't get called for
> > > > > > > DomainObject since it was not in the original list of entities to 
> > > > > > > map.
> > > > > > > It's AutoMap<DomainObject> created by ForTypesThatDeriveFrom is 
> > > > > > > meant
> > > > > > > only to be used by MergeMapping to merge with automaps for classes
> > > > > > > deriving from DomainObject and instead it went to AddMapping. As a
> > > > > > > result it circumvents the checks and ends up getting mapped. Not
> > > > > > > having an Id property, Nhibernate doesn't like that and hence the
> > > > > > > exception. I haven't actually checked the call stacks to verify 
> > > > > > > this
> > > > > > > behaviour - it's all been mental compiler since the realization 
> > > > > > > just
> > > > > > > came to me. :) I'll check it out when I'm at work but it seems to 
> > > > > > > be
> > > > > > > pointing at a loophole in the CompileMapping logic.
>
> > > > > > > On Feb 10, 10:54 pm, Jimit <jimitndi...@gmail.com> wrote:
> > > > > > > > This is my test fixture. I configure FNH in the Setup:
>
> > > > > > > >     [TestFixture]
> > > > > > > >     public class PersistenceTests
> > > > > > > >     {
> > > > > > > >         #region Setup/Teardown
>
> > > > > > > >         [SetUp]
> > > > > > > >         public void SetUp()
> > > > > > > >         {
> > > > > > > >             _sessionFactory = Fluently.Configure()
> > > > > > > >                 .Database(SQLiteConfiguration.Standard.InMemory)
> > > > > > > >                 .Mappings(m => 
> > > > > > > > m.AutoMappings.Add(Mapper.Mappings))
> > > > > > > >                 .ExposeConfiguration(cfg => new SchemaExport
> > > > > > > > (cfg).Create(true, true))
> > > > > > > >                 .BuildSessionFactory();
> > > > > > > >         }
>
> > > > > > > >         [TearDown]
> > > > > > > >         public void TearDown()
> > > > > > > >         {
> > > > > > > >             _sessionFactory = null;
> > > > > > > >         }
>
> > > > > > > >         #endregion
>
> > > > > > > >         private ISessionFactory _sessionFactory;
>
> > > > > > > >         [Test]
> > > > > > > >         public void Can_Map_Orders_To_Database()
> > > > > > > >         {
> > > > > > > >             new PersistenceSpecification<Order>
> > > > > > > > (_sessionFactory.OpenSession())
> > > > > > > >                 .CheckProperty(o => o.Reference, "Order Ref 1")
> > > > > > > >                   .CheckProperty(o => o.PartsOrdered, 2) /* and 
> > > > > > > > so
> > > > > > > > on...*/
> > > > > > > >                 .CheckProperty(o => o.PartsReceived, 1);
> > > > > > > >         }
>
> > > > > > > >     }
>
> > > > > > > > Mapper.Mappings is where the AutoPersistenceModel is defined. 
> > > > > > > > Here
> > > > > are
> > > > > > > > the pertinent parts there:
>
> > > > > > > > public static class Mapper
> > > > > > > > {
> > > > > > > >         public static AutoPersistenceModel Mappings
> > > > > > > >         {
> > > > > > > >             get
> > > > > > > >             {
> > > > > > > >                 return _mappings ?? (_mappings = 
> > > > > > > > DefineMappings());
> > > > > > > >             }
> > > > > > > >         }
>
> > > > > > > >         private static AutoPersistenceModel DefineMappings()
> > > > > > > >         {
> > > > > > > >             return AutoPersistenceModel
> > > > > > > >                 .MapEntitiesFromAssemblyOf<Order>()
> > > > > > > >                 .Where(EntityFilter)
> > > > > > > >                 .WithConvention(DefineConventions)
> > > > > > > >                 .WithCustomMappingsFrom<CustomMappings>();
> > > > > > > >         }
>
> > > > > > > >         private static void DefineConventions
> > > > > > > > (FluentNHibernate.Conventions conventions)
> > > > > > > >         {
> > > > > > > >             SetDefaultConventions(conventions);
> > > > > > > >             AddCustomConventions(conventions);
> > > > > > > >         }
> > > > > > > >         private static void SetDefaultConventions
> > > > > > > > (FluentNHibernate.Conventions conventions)
> > > > > > > >         {
> > > > > > > >             conventions.GetPrimaryKeyName = property => 
> > > > > > > > property.Name
> > > > > > > > + "Id";
> > > > > > > >             conventions.GetPrimaryKeyNameFromType = type => 
> > > > > > > > type.Name
> > > > > > > > + "Id";
> > > > > > > >             conventions.GetVersionColumnName = property => 
> > > > > > > > "Version";
> > > > > > > >             conventions.IsBaseType = type =>
> > > > > > > >                                      type == typeof (object) ||
> > > > > > > >                                      type == typeof 
> > > > > > > > (DomainObject) ||
> > > > > > > >                                      (type.IsGenericType
> > > > > > > >                                       &&
> > > > > type.GetGenericTypeDefinition
> > > > > > > > ().IsIn(new[]
>
> > > > > > > > {
>
> > > > > > > > typeof (EntityBase<,>),
>
> > > > > > > > typeof (EntityBase<>),
>
> > > > > > > > typeof (ProcessedEntity<,>),
>
> > > > > > > > typeof (ProcessedEntity<>),
>
> > > > > > > > typeof (AuditedEntity<,>),
>
> > > > > > > > typeof (AuditedEntity<>),
>
> > > > > > > > typeof (ProcessingEvent<>)
>
> > > > > > >         }));
> > > > > > > >             //conventions.IsComponentType = t => t ==
> > > > > typeof(Address);
> > > > > > > >             conventions.OneToManyConvention = map =>
> > > > > > > > map.Cascade.SaveUpdate();
> > > > > > > >             conventions.DefaultLazyLoad = true;
> > > > > > > >             conventions.GetForeignKeyNameOfParent = parent =>
> > > > > > > > parent.Name + "ID";
> > > > > > > >
>
> ...
>
> read more ยป
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to