Thanks for the response. I'll have a try tonight! If I succeed I'll send you
a patch

On Fri, Oct 3, 2008 at 10:21 AM, Andrew Stewart <
[EMAIL PROTECTED]> wrote:

> Hi
> I've had a "very" quick look at what your trying to do, and here's the
> problem. I don't see a reason why this can't be achieved, although we don't
> currently support it - to add support you'd have to do something like below:
>
> Modify the convention class to hold your convention and create a class that
> can perform your mapping automatically, and inject it into AutoMapper as
> below:
>
>> i        public AutoMapper(Conventions conventions)
>>
>         {
>>
>             _mappingRules = new List<IAutoMapper>
>>
>                                 {
>>
>                                     new AutoMapIdentity(conventions),
>>
>                                     new AutoMapVersion(conventions),
>>
>                                     new AutoMapColumn(conventions),
>
>                                        new AutoMapComponent(conventions),
>
>>                                     new AutoMapManyToOne(),
>>
>                                     new AutoMapOneToMany(),
>>
>                                 };
>>
>         }
>
>
> You'd then have to modify create the AutoMapComponent class which will
> implement the logic to automapping logic for a component. Which is basically
> a class that implments IAutoMapper, you see examples in any of the above
> classes. Hope that helps, if you manage to achieve it, please send me a
> patch and i'll get it put into the trunk.
>
> Cheers
>
> Andy
>
> On Fri, Oct 3, 2008 at 8:16 AM, Gabriel Schenker <[EMAIL PROTECTED]>wrote:
>
>> I have now a working version with (code snippet...)
>>
>>
>> .ForTypesThatDeriveFrom<Person>(map=>map.Component<Address>(t=>t.Address,
>>                     c=>
>>                         {
>>                             c.Map(p => p.Line1);
>>                             c.Map(p => p.Line2);
>>                             c.Map(p => p.PostalCode);
>>                             c.Map(p => p.City);
>>                             c.References(p => p.Country);
>>                         }))
>>
>> but since I have many different value objects this cannot be the solution!
>> I don't want to manually define all my mappings of value objects
>>
>> I wonder if it is not possible to define a convention for the mapping of
>> value objects? Something like
>>
>> AutoPersistenceModel
>>         .MapEntitiesFromAssemblyOf<Person>()
>>         *.WithConvention(c => c.MapAsComponent = type =>
>> IsValueObject(type))*
>>
>> where the function *IsValueObject(...) *is a user defined function...
>>
>> would this be possible?
>>
>>
>>  On Thu, Oct 2, 2008 at 11:37 PM, Andrew Stewart <
>> [EMAIL PROTECTED]> wrote:
>>
>>> Hi Gabriel
>>> To be honest mate, no idea- as I've never actually done it with the
>>> normal fluent-nhibernate.
>>>
>>> However if fluent-nhibernate supports it then AutoMapper supports it.
>>> Basically AutoPersitenceModel will map out as much of your model as it can
>>> figure out by it self then it's down to you to provide the extra's. To
>>> attempt to point you in the write direction it should be something like the
>>> below:
>>>
>>> AutopersistenceModel
>>> .MapEntitiesFromAssembly<EntityName>()
>>> .Where( t => t.Namespace=="YourNamespace")
>>> .ForTypesDerivedFromType<Person>( map =>
>>> {
>>> /// Normal Fluent nibernate code goes here.
>>> })
>>> .Configure();
>>>
>>> This is all from memory, so it's probably slightly off. I'll be in work
>>> in the morning and can probably send you a more accurate example then.
>>>
>>> Good luck, let me know how you get on.
>>>
>>> Andy
>>>
>>> On Thu, Oct 2, 2008 at 10:13 PM, Gabriel Schenker <[EMAIL PROTECTED]>wrote:
>>>
>>>>
>>>> How do I configure my AutoPersistenceModel when using components? E.g
>>>>
>>>> Person-->Address
>>>>
>>>> where Person is an entity and Address is a value object (=component)?
>>>>
>>>>
>>>
>>>
>>> --
>>> =================
>>> I-nnovate Software - Bespoke Software Development, uk wirral.
>>> http://www.i-nnovate.net
>>>
>>>
>>>
>>
>>
>>
>
>
> --
> =================
> 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