Hi Nick
Sorry for the delay must be the busiest week ever. Here we go, personally I
tend to find my entities with a namespace.
For example

.Where(t => t.Namespace == "Program.Entities")

The problem is I don't know your app layout enough to give you advice on how
to find your entities.

No for Ignoring properties, AutoMapping will by default ignore any property
that doesn't have a setter. Also as of 30 seconds ago I've just checked in
the below syntax for you.

var autoMapper = AutoPersistenceModel
>
                .MapEntitiesFromAssemblyOf<ExampleClass>()
>
                .Where(t => t.Namespace ==
> "FluentNHibernate.AutoMap.TestFixtures")
>
                .ForTypesThatDeriveFrom<ExampleCustomColumn>(c =>
> c.IgnoreProperty(p => p.ExampleCustomColumnId));
>

Hope that helps, don't hesitate to ask if you need any more information.

Cheers

Andy

On Mon, Oct 27, 2008 at 5:34 PM, Nick72 <[EMAIL PROTECTED]> wrote:

>
> I'm getting started with auto mapping and have a few questions:
>
> 1. var autoMapper = AutoPersistenceModel
>                                .MapEntitiesFromAssemblyOf<Customer>()
>                                .Where(t => (t.BaseType == typeof
> (EntityBase<>)));
>
> Doesn't work, because EntityBase is an unspecified generic type. So, I
> have:
>
> var autoMapper = new AutoPersistenceModel()
>
>  .AddEntityAssembly(Assembly.Load("LAA.Domain"))
>                                .Where(t => t.IsEntity());
>
> With an extension method in my domain:
>
> public static bool IsEntity(this Type typeToCheck)
>                {
>                        if (typeToCheck.IsAbstract ||
> typeToCheck.IsGenericType)
>                                return false;
>
>                        while (typeToCheck != typeof(object))
>                        {
>                                if (typeToCheck.IsGenericType &&
> typeToCheck.GetGenericTypeDefinition() == typeof(EntityBase<>))
>                                        return true;
>
>                                typeToCheck = typeToCheck.BaseType;
>                        }
>
>                        return false;
>                }
>
> Is there an better way of handling this?
>
> 2. I would like to handle exclusions so I can customize my mappings.
> To exclude an entity, it's easy enough with:
>
> .Where(t => (t.BaseType == typeof (EntityBase<>) && t !=
> typeof(TypeToExclude)));
>
> I'd also like to exclude properties from being mapped. I realize I
> could exclude an entity and map it myself, but it would be nice to
> auto map the entity and then exclude one of the properties mapped. I
> think one could do this with:
>
> var p =
>
> autoMapper.FindMapping<Customer>().PropertiesMapped.Remove(somePropertyInfo);
>
> However, the auto mapping finds mappings and generates the mapping
> objects and outputs them in one fell swoop in the Configure method, so
> it's impossible to get to the mapping objects before they've been
> outputted. Would it be possible to something like:
>
> autoMapper.GenerateMappings();
>
> autoMapper.FindMapping<Customer>().PropertiesMapped.Remove(somePropertyInfo);
> autoMapper.Configure(nHibConfig);
> >
>


-- 
=================
I-nnovate Software - Bespoke Software Development, uk wirral.
http://www.i-nnovate.net

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to