I have the following entity classes:

public class Address
{
public virtual string Line1 {get; set;}
public virtual string Line2 {get; set;}
}

public class Customer
{
public virtual string Name{get; set;}
public virtual Address Address {get; set;}
}

I'm currently using FluentMappings (Via ClassMap) to manually create
the mappings for these entities, and they all work correctly. I now
want to add a base class (EntityBase, see below) to each of my
entities.

public class EntityBase
{
public virtual int Id {get; set;}
[Other properties/methods that NHibernate should ignore]
}

public class Address : EntityBase{....
public class Customer: EntityBase{....

When I do this I get an exception when calling BuildSessionFactory()
telling me that all my properties and methods in my base class must be
declared as virtual. Is there a way I can configure the manual
mappings to ignore the base class properties/methods. I would prefer
to avoid using AutoMapping, as I've attempted to do the mappings using
AutoMap with little success, but would gladly use AutoMapping just to
configure the base type. I've tried mixing the two approachs (see
below), but it did not work as I expected. Here is the mappings
section including the attempted automap for the base class, note that
this DID NOT WORK.

.Mappings(m =>
                    {
                        // Configure the Fluent Mappings
                        m.FluentMappings
                            .AddFromAssemblyOf<ClientMap>()
                            .ExportTo(@"C:\Projects\TourChoice
\SolutionItems\HbmMappings\Fluent\");

                        // Configure the AutoMap
Mappings
                        m.AutoMappings
                            .Add(AutoPersistenceModel
                            .MapEntitiesFromAssemblyOf<EntityBase>()
                            .WithSetup(s =>
                            {
                                s.IsBaseType = type => type == typeof
(EntityBase);
                            })
                            .Where(t => t.Namespace ==
"My.Namespace"))
                    });



I've read all the documentation on the site but can't find any details
on how to do this. Any help would be much appreciated.
--~--~---------~--~----~------------~-------~--~----~
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