I think your modification will work. But what's confusing is that, why I 
have to define both convention and explicit mapping?
It's ConventionModelMapper, I think I only need to define the convention 
and that's done?
Maybe the ConventionModelMapper should handle the version column mapping?
It seems that ConventionModelMapper defines IsVersion convention but it 
doesn't handle the mapping for version column.

On Friday, April 18, 2014 5:27:08 PM UTC+8, Ricardo Peres wrote:
>
> I think you are mixing convention and explicit mapping. Your first example 
> should be more like:
>
> var mapper = new ConventionModelMapper();
> mapper.IsVersion((m, d) => m.Name == "Version");
> mapper.BeforeMapProperty((model, member, propertyCustomizer) =>
> {
>   if (this.IsVersion(member.LocalMember, true) == true)
>   {
>     propertyCustomizer.Generated(PropertyGeneration.Never);
>   }
>   ...
> });
>
> var types = ...;
> var mapping = mapper.CompileMappingFor(types);
>
> var cfg = ...;
> cfg.AddMapping(mapping);
>
> Can you try this?
>
> RP
>
> On Thursday, April 17, 2014 6:10:48 PM UTC+1, Mouhong Lin wrote:
>>
>> Hi guys,
>>
>> I use *NHibernate 3.3.1.4000* See the following code:
>>
>>             var mapper = new ConventionModelMapper();
>>
>>             mapper.IsVersion((m, d) => m.Name == "Version");
>>
>>             mapper.Class<Campaign>(x =>
>>             {
>>                 x.Id(c => c.Id, m => m.Generator(Generators.Assigned));
>>
>>                 x.Property(c => c.Title);
>>                 x.Property(c => c.Price);
>>             });
>>
>>             
>> config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
>>
>> With this configuration. The Campaign.Version will not worked as a 
>> Version property. The value will never increased.
>> But if I use explicit mapping like this:
>>
>>             var mapper = new ConventionModelMapper();
>>
>>             mapper.Class<Campaign>(x =>
>>             {
>>                 x.Id(c => c.Id, m => m.Generator(Generators.Assigned));
>>
>>                 x.Property(c => c.Title);
>>                 x.Property(c => c.Price);
>>
>>                 x.Version(c => c.Version, m => 
>> m.Generated(VersionGeneration.Never));
>>             });
>>
>>             
>> config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
>>
>>
>> It works!! But *why the ConventionModelMapper doesn't work? How can I 
>> get the convention mapper work? *Thanks
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to