Hello again.

One quick thing, it seems at the moment, the property that timestamps must
be called version or timestamp, otherwise you'll have to manually map it.

I tried using Timestamp but then NH tries to use datetime. That's why I'm
using a custom user type and it seems like it's working (at least the
PersistenceSpecification isn't throwing any errors.

So, what I need is to add this from my manual mapping class:


Version(d => d.Versao)
                .TheColumnNameIs("Versao")
                .SetAttributes(
                            new Attributes
                                      {
                                          {"type",
"ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
                                          {"unsaved-value", "null"},
                                          {"generated", "always"}
                                      }
                );

So that it is applied to all the types that derive from EntidadeBase class.
I tried this:

var modeloPersistencia =
AutoPersistenceModel.MapEntitiesFromAssemblyOf<Disciplina>()
                .Where(
                type => type == typeof (Disciplina)
                ) //comecar com disciplina
                .WithConvention(convention =>
                                    {
                                        convention.DefaultLazyLoad = false;
                                        convention.FindIdentity = field =>
field.Name == "Id";
                                        convention.GetTableName = type =>
String.Concat(type.Name, "s");
                                        convention.GetVersionColumnName =
type => "Versao";
                                      
                                            
                                        convention.GetPrimaryKeyNameFromType
= type => String.Concat("Id", type.Name);
                                        convention.IsBaseType = type => type
== typeof (EntidadeBase);
                                    });
            modeloPersistencia.ForTypesThatDeriveFrom<EntidadeBase>(
                eb => 
                    eb.Version(d => d.Versao)
                          .TheColumnNameIs("Versao")
                          .SetAttributes(
                          new Attributes
                              {
                                  {"type",
"ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
                                  {"unsaved-value", "null"},
                                  {"generated", "always"}
                              }
                          ));

But by doing this it insists on generating a class definition for
Entidadebase....

Thanks.

Luis



--~--~---------~--~----~------------~-------~--~----~
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 
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