/// <summary> /// Generates a VersionProperty representation for an entity mapping given its /// version mapping Property. /// </summary> /// <param name="property">The version mapping Property.</param> /// <param name="lazyAvailable">Is property lazy loading currently available.</param> /// <returns>The appropriate VersionProperty definition.</returns> public static VersionProperty BuildVersionProperty(Mapping.Property property, bool lazyAvailable) { String mappedUnsavedValue = ((IKeyValue)property.Value).NullValue; VersionValue unsavedValue = UnsavedValueFactory.GetUnsavedVersionValue( mappedUnsavedValue, GetGetter(property), (IVersionType)property.Type, GetConstructor(property.PersistentClass) ); bool lazy = lazyAvailable && property.IsLazy; return(new VersionProperty( property.Name, property.NodeName, property.Value.Type, lazy, property.IsInsertable, property.IsUpdateable, property.Generation == PropertyGeneration.Insert || property.Generation == PropertyGeneration.Always, property.Generation == PropertyGeneration.Always, property.IsOptional, property.IsUpdateable && !lazy, property.IsOptimisticLocked, property.CascadeStyle, unsavedValue )); }
/// <summary> /// Generates an IdentifierProperty representation of the for a given entity mapping. /// </summary> /// <param name="mappedEntity">The mapping definition of the entity.</param> /// <param name="generator">The identifier value generator to use for this identifier.</param> /// <returns>The appropriate IdentifierProperty definition.</returns> public static IdentifierProperty BuildIdentifierProperty(PersistentClass mappedEntity, IIdentifierGenerator generator) { string mappedUnsavedValue = mappedEntity.Identifier.NullValue; IType type = mappedEntity.Identifier.Type; Mapping.Property property = mappedEntity.IdentifierProperty; IdentifierValue unsavedValue = UnsavedValueFactory.GetUnsavedIdentifierValue(mappedUnsavedValue, GetGetter(property), type, GetConstructor(mappedEntity)); if (property == null) { // this is a virtual id property... return(new IdentifierProperty(type, mappedEntity.HasEmbeddedIdentifier, mappedEntity.HasIdentifierMapper, unsavedValue, generator)); } else { return(new IdentifierProperty(property.Name, property.NodeName, type, mappedEntity.HasEmbeddedIdentifier, unsavedValue, generator)); } }