public ComponentType(ComponentMetamodel metamodel) { // for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907) isKey = metamodel.IsKey; propertySpan = metamodel.PropertySpan; propertyNames = new string[propertySpan]; propertyTypes = new IType[propertySpan]; propertyNullability = new bool[propertySpan]; cascade = new CascadeStyle[propertySpan]; joinedFetch = new FetchMode?[propertySpan]; for (int i = 0; i < propertySpan; i++) { StandardProperty prop = metamodel.GetProperty(i); propertyNames[i] = prop.Name; propertyTypes[i] = prop.Type; propertyNullability[i] = prop.IsNullable; cascade[i] = prop.CascadeStyle; joinedFetch[i] = prop.FetchMode; } ComponentTuplizer = metamodel.ComponentTuplizer; EntityMode = metamodel.EntityMode; if (EntityMode == EntityMode.Poco) { overridesGetHashCode = ReflectHelper.OverridesGetHashCode(ComponentTuplizer.MappedClass); } }
public Property(StandardProperty property) { //this.standard = property; if (property == StandardProperty.none) { Text = AppResources.None; } else { Text = Strings.FromEnum(property); } LowerText = Text.ToLower(); if (property >= StandardProperty.Protein) { Unit = AppResources.Unit_Gram.ToLower(); } if (property >= StandardProperty.Calcium) { Unit = "mg"; } if (property >= StandardProperty.VitaminD) { Unit = "µg"; } ID = GetID(property); }
public virtual object[] GetPropertyValues(object entity) { var uninitializedPropNames = GetUninitializedLazyProperties(entity); int span = entityMetamodel.PropertySpan; object[] result = new object[span]; for (int j = 0; j < span; j++) { StandardProperty property = entityMetamodel.Properties[j]; if (!uninitializedPropNames.Contains(property.Name) || !property.IsLazy) { result[j] = GetPropertyValue(entity, j); } else { result[j] = LazyPropertyInitializer.UnfetchedProperty; } } return(result); }
public virtual object[] GetPropertyValues(object entity) { bool getAll = ShouldGetAllProperties(entity); int span = entityMetamodel.PropertySpan; object[] result = new object[span]; for (int j = 0; j < span; j++) { StandardProperty property = entityMetamodel.Properties[j]; if (getAll || !property.IsLazy) { result[j] = getters[j].Get(entity); } else { result[j] = LazyPropertyInitializer.UnfetchedProperty; } } return(result); }
public ComponentType(ComponentMetamodel metamodel) { // for now, just "re-flatten" the metamodel since this is temporary stuff anyway (HHH-1907) isKey = metamodel.IsKey; propertySpan = metamodel.PropertySpan; propertyNames = new string[propertySpan]; propertyTypes = new IType[propertySpan]; propertyNullability = new bool[propertySpan]; cascade = new CascadeStyle[propertySpan]; joinedFetch = new FetchMode?[propertySpan]; for (int i = 0; i < propertySpan; i++) { StandardProperty prop = metamodel.GetProperty(i); propertyNames[i] = prop.Name; propertyTypes[i] = prop.Type; propertyNullability[i] = prop.IsNullable; cascade[i] = prop.CascadeStyle; joinedFetch[i] = prop.FetchMode; } tuplizerMapping = metamodel.TuplizerMapping; }
private ValueInclusion DetermineUpdateValueGenerationType(Mapping.Property mappingProperty, StandardProperty runtimeProperty) { if (runtimeProperty.IsUpdateGenerated) { return ValueInclusion.Full; } else if (mappingProperty.Value is Mapping.Component) { if (HasPartialUpdateComponentGeneration((Mapping.Component)mappingProperty.Value)) { return ValueInclusion.Partial; } } return ValueInclusion.None; }
private ValueInclusion DetermineInsertValueGenerationType(Mapping.Property mappingProperty, StandardProperty runtimeProperty) { if (runtimeProperty.IsInsertGenerated) { return(ValueInclusion.Full); } else if (mappingProperty.Value is Mapping.Component) { if (HasPartialInsertComponentGeneration((Mapping.Component)mappingProperty.Value)) { return(ValueInclusion.Partial); } } return(ValueInclusion.None); }
private static string GetID(StandardProperty property) { return(((int)property).ToString().PadLeft(2, '0')); }
/// <summary> /// Recursive Helper for <see cref="IsReferencedByCompositeId(IEntityPersister)"/>. /// </summary> /// <param name="rootEM"></param> /// <param name="nestedEM"></param> /// <param name="neestedIsCompositeId"></param> /// <param name="visitedList"></param> /// <returns></returns> private EntityMetamodel GetReferrerByCompositeId( EntityMetamodel rootEM, EntityMetamodel nestedEM, bool neestedIsCompositeId, ICollection <EntityMetamodel> visitedList) { EntityMetamodel emResult = null; if (visitedList.Contains(nestedEM)) { return(emResult); } else { visitedList.Add(nestedEM); ISessionFactoryImplementor sessionImplementor = rootEM.SessionFactory; if (nestedEM.IdentifierProperty.Type is IAbstractComponentType) { IAbstractComponentType componentType = (IAbstractComponentType)nestedEM.IdentifierProperty.Type; for (int i = 0; i < componentType.Subtypes.Length; i++) { IType subType = componentType.Subtypes[i]; if (!subType.IsAnyType && subType.IsAssociationType && subType is IAssociationType) { IAssociationType associationType = (IAssociationType)subType; string associatedEntityName = null; try { //for 'Collection Types', sometimes 'Element Type' is not an 'Entity Type' associatedEntityName = associationType.GetAssociatedEntityName(sessionImplementor); } catch (MappingException me) { //I think it will never happen because a //"Composit Id" can not have a property that //uses 'NHibernate.Type.CollectionType'. //But just in case ... if (log.IsDebugEnabled) { log.Debug("Can not perform 'GetAssociatedEntityName'. " + "Considering it is not an entity type: '" + nestedEM.IdentifierProperty.Name + "." + componentType.PropertyNames[i] + "'" , me); } } if (associatedEntityName != null) { IEntityPersister persisterNextNested = sessionImplementor.GetEntityPersister(associatedEntityName); if (rootEM == persisterNextNested.EntityMetamodel) { emResult = nestedEM; return(emResult); } else { emResult = this.GetReferrerByCompositeId( rootEM, persisterNextNested.EntityMetamodel, true, visitedList); if (emResult != null) { return(emResult); } } } } } } for (int i = 0; i < nestedEM.Properties.Length; i++) { StandardProperty property = nestedEM.Properties[i]; if (!property.Type.IsAnyType && property.Type.IsAssociationType && property.Type is IAssociationType) { IAssociationType associationType = (IAssociationType)property.Type; string associatedEntityName = null; try { //for 'Collection Types', sometimes 'Element Type' is not an 'Entity Type' associatedEntityName = associationType.GetAssociatedEntityName(sessionImplementor); } catch (MappingException me) { if (log.IsDebugEnabled) { log.Debug("Can not perform 'GetAssociatedEntityName'. " + "Considering it is not an entity type: '" + nestedEM.EntityType.Name + "." + nestedEM.PropertyNames[i] + "'", me); } } if (associatedEntityName != null) { IEntityPersister persisterNextNested = sessionImplementor.GetEntityPersister(associatedEntityName); emResult = this.GetReferrerByCompositeId( rootEM, persisterNextNested.EntityMetamodel, false, visitedList); if (emResult != null) { return(emResult); } } } } } return(null); }