Okay, I've moved one step closer to a viable solution. I've managed to
remove these lines:

  mapping.IgnoreProperty(x => x.EntityId);
  mapping.IgnoreProperty(x => x.RequestedRevision);
  mapping.IgnoreProperty(x => x.IsCurrent);

from the utility and made the equivalent logic in an
IAutomappingConfiguration object's "ShouldMap" method. The only thing
left in the utility and mapping overrides now is:

  mapping.References(x => x.Current, "CurrentId");
  mapping.HasMany(x => x.Revisions).KeyColumn("CurrentId");
  mapping.ApplyFilter<LogicalDeleteFilter>();

Is there any way to do .References(), .HasMany() and .ApplyFilter() in
IAutomappingConfiguration or in a convention? I'm now 3 lines of code
away from being able to delete 30 mapping files! Please help me! :)


-Asbjørn


On Sep 16, 11:09 am, Asbjørn Ulsberg <asbjo...@gmail.com> wrote:
> I have the following base class for most of my entities:
>
>    public abstract class RevisableEntity<TCurrentEntity, TEntityRevision> :  
> Entity
>      where TCurrentEntity :
>            RevisableEntity<TCurrentEntity, TEntityRevision>,
>            ICurrentEntity<TCurrentEntity, TEntityRevision>
>      where TEntityRevision :
>            RevisableEntity<TCurrentEntity, TEntityRevision>,
>            IEntityRevision<TCurrentEntity, TEntityRevision>
>    {
>    }
>
> I would like -- no, love! -- if it was able to map everything inside of  
> classes inheriting from RevisableEntity with one or more conventions. I've  
> tried to make an abstract base class that implements  
> 'IAutoMappingOverride<RevisableEntity<TCurrentEntity, TEntityRevision>>'  
> but Fluent didn't like that much. Having maps that are abstract seems like  
> a completely unsupported scenario and Fluent throws instead of ignoring  
> the mappings. I would prefer ignoring, obviously.
>
> Either way, I would need to have a specific, non-abstract, non-generic  
> version of the above mentioned override for all of my entities either way,  
> which is a pain. I'm now in even more pain because the code I would like  
> to have in the generic abstract mapping override, I've had to put into  
> what I've called 'RevisableEntityUtility.OverrideMapping()' which I'm  
> forced to invoke in all mapping overrides.
>
> Since all of my revisable entities are double (one being 'current' and one  
> being 'revision'), this means that for every revisable entity I have in my  
> domain model, I need two maps. Oh the pain! I'm seeking a way to solve  
> this with one or more conventions, but have found none that will help me  
> in any way. Here's what's going on inside  
> 'RevisableEntityUtility.OverrideMapping()':
>
>    mapping.IgnoreProperty(x => x.EntityId);
>    mapping.IgnoreProperty(x => x.RequestedRevision);
>    mapping.IgnoreProperty(x => x.IsCurrent);
>    mapping.ApplyFilter<LogicalDeleteFilter>();
>
> What's even worse is that I can't have all the code I want inside the  
> utility, because that leads to what has to be a bug in Fluent. In the  
> 'current' maps I want to have a list of all the revisions of the same  
> entity:
>
>    mapping.HasMany(x => x.Revisions)
>           .KeyColumn("CurrentId")
>           .OrderBy("GlobalRevisionNumberId");
>
> And in the 'revision' maps I want to have a reference to the 'current' of  
> the same entity:
>
>    mapping.References(x => x.Current, "CurrentId");
>
> If I try to map this inside the utility, for whatever reason, I get the  
> following error:
>
>    ----> System.InvalidOperationException : Tried to add collection  
> 'Revisions' when already added.
>    ----> System.InvalidOperationException : Tried to add reference  
> 'Current' when already added.
>
> If I move the .HasMany and .References call up from the utility to the  
> individual maps, it works. I have absolutely no idea why this isn't  
> working. Either way I would like to just get rid of all of my maps and do  
> all of this with conventions. Do I have any hope of achieving this with  
> Fluent? Can someone please point me in the right direction?
>
> --
> Asbjørn Ulsberg           -=|=-        asbj...@ulsberg.no
> «He's a loathsome offensive brute, yet I can't look away»

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@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