Yeah Paul, that was me. Someone else suggested using attributes and looking for those on the Where filter. I'd be up for upgrading to 1.0RC, but you know the pains of "running with scissors" and open source projects. Upgrading to FNH means upgrading NH means upgrading NH.Validator means upgrading all SharpArch libs means upgrading all my libs and hoping it all works. Uggggh, I'm running out of time and beginning to evaluate some shortcuts at this point.
Thanks anyway, cc On Aug 18, 9:22 am, Paul Batum <[email protected]> wrote: > I think I was attempting to help you with this on another thread wasn't I > Corey? > > I'm not surprised its driving you crazy, it all looks fine. At this point > I'd look into either: > a) getting some debug symbols loaded for fnh and step into the automapper > code. > g) try upgrading to 1.0RC, there are many fixes for all sorts of problems in > that release. > > On Tue, Aug 18, 2009 at 8:37 PM, Corey Coogan <[email protected]> wrote: > > > This seemingly simple problem has been driving me crazy. I want to > > exclude some entities from the Auto Mapper. I don't want to automap > > the User class or it's subclasses. I added the filter to the > > GetAutoMappingFilter delegate that is passed into the > > AutoPersistenceModel.Where filter method, but it still gets mapped. I > > can debug and see that this method return False for my desired > > exclusions, but they are mapped anyway. > > > /// <summary> > > /// Provides a filter for only including types which inherit > > from the IEntityWithTypedId interface. > > /// </summary> > > private bool GetAutoMappingFilter(Type t) > > { > > bool isUser = t.BaseType == typeof(User) || > > t.IsAssignableFrom(typeof(Teacher)); > > > bool isIEntity = t.GetInterfaces().Any(x => > > x.IsGenericType && x.GetGenericTypeDefinition() == > > typeof(IEntityWithTypedId<>) > > ); > > > return !isUser && isIEntity; > > } > > > Here's my entire AutoPersistenceModelGenerator class: > > > public class AutoPersistenceModelGenerator : > > IAutoPersistenceModelGenerator > > { > > public AutoPersistenceModel Generate() > > { > > AutoPersistenceModel mappings = AutoPersistenceModel > > // If you delete the default class, simply point the > > following line to an entity within the .Core layer > > .MapEntitiesFromAssemblyOf<Celebration>() > > .Where(GetAutoMappingFilter) > > .ConventionDiscovery.Setup(GetConventions()) > > .WithSetup(GetSetup()) > > .UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator> > > () > > ; > > > return mappings; > > } > > > private Action<AutoMappingExpressions> GetSetup() > > { > > return c => > > { > > c.FindIdentity = type => type.Name == "Id"; > > c.IsBaseType = IsBaseTypeConvention; > > c.IsComponentType = type => type.IsSubclassOf(typeof > > (ValueObject)); > > }; > > } > > > private Action<IConventionFinder> GetConventions() > > { > > return c => > > { > > c.Add<PrimaryKeyConvention>(); > > c.Add<ReferenceConvention>(); > > c.Add<HasManyConvention>(); > > c.Add<TableNameConvention>(); > > }; > > } > > > /// <summary> > > /// Provides a filter for only including types which inherit > > from the IEntityWithTypedId interface. > > /// </summary> > > private bool GetAutoMappingFilter(Type t) > > { > > bool isUser = t.BaseType == typeof(User) || > > t.IsAssignableFrom(typeof(Teacher)); > > > bool isIEntity = t.GetInterfaces().Any(x => > > x.IsGenericType && x.GetGenericTypeDefinition() == > > typeof(IEntityWithTypedId<>) > > ); > > > return !isUser && isIEntity; > > } > > > private bool IsBaseTypeConvention(Type arg) > > { > > bool derivesFromEntity = arg == typeof(Entity); > > > bool derivesFromEntityWithTypedId = arg.IsGenericType && > > (arg.GetGenericTypeDefinition() == typeof > > (EntityWithTypedId<>)); > > > return (derivesFromEntity || > > derivesFromEntityWithTypedId); > > } > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
