Exemple #1
0
        /// <summary>
        /// For a component, add to a list of associations to be fetched by outerjoin
        /// </summary>
        protected void WalkComponentTree(IAbstractComponentType componentType, int begin, string alias, string path,
                                         int currentDepth, ILhsAssociationTypeSqlInfo associationTypeSQLInfo)
        {
            IType[]  types         = componentType.Subtypes;
            string[] propertyNames = componentType.PropertyNames;
            for (int i = 0; i < types.Length; i++)
            {
                if (types[i].IsAssociationType)
                {
                    var associationType = (IAssociationType)types[i];

                    string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, begin);
                    string[] lhsColumns        = associationTypeSQLInfo.GetColumnNames(associationType, begin);
                    string   lhsTable          = associationTypeSQLInfo.GetTableName(associationType);

                    string subpath             = SubPath(path, propertyNames[i]);
                    bool[] propertyNullability = componentType.PropertyNullability;

                    JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns,
                                                    propertyNullability == null || propertyNullability[i], currentDepth,
                                                    componentType.GetCascadeStyle(i));

                    AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType);
                }
                else if (types[i].IsComponentType)
                {
                    string subpath = SubPath(path, propertyNames[i]);

                    WalkComponentTree((IAbstractComponentType)types[i], begin, alias, subpath, currentDepth, associationTypeSQLInfo);
                }
                begin += types[i].GetColumnSpan(Factory);
            }
        }
Exemple #2
0
        /// <summary>
        /// For a composite element, add to a list of associations to be fetched by outerjoin
        /// </summary>
        private void WalkCompositeElementTree(IAbstractComponentType compositeType, string[] cols,
                                              IQueryableCollection persister, string alias, string path, string subPathAlias, int currentDepth)
        {
            IType[]  types         = compositeType.Subtypes;
            string[] propertyNames = compositeType.PropertyNames;
            int      begin         = 0;

            for (int i = 0; i < types.Length; i++)
            {
                int      length     = types[i].GetColumnSpan(factory);
                string[] lhsColumns = ArrayHelper.Slice(cols, begin, length);

                if (types[i].IsAssociationType)
                {
                    IAssociationType associationType = types[i] as IAssociationType;

                    // simple, because we can't have a one-to-one or collection
                    // (or even a property-ref) in a composite element:
                    string[] aliasedLhsColumns   = StringHelper.Qualify(alias, lhsColumns);
                    string   subpath             = SubPath(path, propertyNames[i]);
                    bool[]   propertyNullability = compositeType.PropertyNullability;

                    var joinType =
                        GetJoinType(
                            associationType,
                            compositeType.GetFetchMode(i),
                            subpath,
                            alias,
                            persister.TableName,
                            lhsColumns,
                            propertyNullability == null || propertyNullability[i],
                            currentDepth,
                            compositeType.GetCascadeStyle(i));

                    AddAssociationToJoinTreeIfNecessary(
                        associationType,
                        aliasedLhsColumns,
                        alias,
                        subpath,
                        subPathAlias,
                        currentDepth,
                        joinType);
                }
                else if (types[i].IsComponentType)
                {
                    string subpath = SubPath(path, propertyNames[i]);
                    WalkCompositeElementTree(
                        (IAbstractComponentType)types[i],
                        lhsColumns,
                        persister,
                        alias,
                        subpath,
                        subPathAlias,
                        currentDepth);
                }
                begin += length;
            }
        }
Exemple #3
0
 private void CascadeComponent(object parent, object child, IAbstractComponentType componentType, object anything)
 {
     object[] children = componentType.GetPropertyValues(child, eventSource);
     IType[]  types    = componentType.Subtypes;
     for (int i = 0; i < types.Length; i++)
     {
         CascadeStyle componentPropertyStyle = componentType.GetCascadeStyle(i);
         if (componentPropertyStyle.DoCascade(action))
         {
             CascadeProperty(parent, children[i], types[i], componentPropertyStyle, anything, false);
         }
     }
 }
Exemple #4
0
 private async Task CascadeComponentAsync(object parent, object child, IAbstractComponentType componentType, string componentPropertyName, object anything, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     componentPathStack.Push(componentPropertyName);
     object[] children = await(componentType.GetPropertyValuesAsync(child, eventSource, cancellationToken)).ConfigureAwait(false);
     IType[]  types    = componentType.Subtypes;
     for (int i = 0; i < types.Length; i++)
     {
         CascadeStyle componentPropertyStyle = componentType.GetCascadeStyle(i);
         string       subPropertyName        = componentType.PropertyNames[i];
         if (componentPropertyStyle.DoCascade(action))
         {
             await(CascadePropertyAsync(parent, children[i], types[i], componentPropertyStyle, subPropertyName, anything, false, cancellationToken)).ConfigureAwait(false);
         }
     }
     componentPathStack.Pop();
 }
		/// <summary>
		/// For a composite element, add to a list of associations to be fetched by outerjoin
		/// </summary>
		private void WalkCompositeElementTree(IAbstractComponentType compositeType, string[] cols,
			IQueryableCollection persister, string alias, string path, int currentDepth)
		{
			IType[] types = compositeType.Subtypes;
			string[] propertyNames = compositeType.PropertyNames;
			int begin = 0;
			for (int i = 0; i < types.Length; i++)
			{
				int length = types[i].GetColumnSpan(factory);
				string[] lhsColumns = ArrayHelper.Slice(cols, begin, length);

				if (types[i].IsAssociationType)
				{
					IAssociationType associationType = types[i] as IAssociationType;

					// simple, because we can't have a one-to-one or collection
					// (or even a property-ref) in a composite element:
					string[] aliasedLhsColumns = StringHelper.Qualify(alias, lhsColumns);
					string subpath = SubPath(path, propertyNames[i]);
					bool[] propertyNullability = compositeType.PropertyNullability;

					JoinType joinType =
						GetJoinType(associationType, compositeType.GetFetchMode(i), subpath, persister.TableName, lhsColumns,
												propertyNullability == null || propertyNullability[i], currentDepth, compositeType.GetCascadeStyle(i));

					AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType);
				}
				else if (types[i].IsComponentType)
				{
					string subpath = SubPath(path, propertyNames[i]);
					WalkCompositeElementTree((IAbstractComponentType)types[i], lhsColumns, persister, alias, subpath, currentDepth);
				}
				begin += length;
			}
		}
		/// <summary>
		/// For a component, add to a list of associations to be fetched by outerjoin
		/// </summary>
		protected void WalkComponentTree(IAbstractComponentType componentType, int begin, string alias, string path,
		                                 int currentDepth, ILhsAssociationTypeSqlInfo associationTypeSQLInfo)
		{
			IType[] types = componentType.Subtypes;
			string[] propertyNames = componentType.PropertyNames;
			for (int i = 0; i < types.Length; i++)
			{
				if (types[i].IsAssociationType)
				{
					var associationType = (IAssociationType) types[i];

					string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, begin);
					string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, begin);
					string lhsTable = associationTypeSQLInfo.GetTableName(associationType);

					string subpath = SubPath(path, propertyNames[i]);
					bool[] propertyNullability = componentType.PropertyNullability;

					JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns,
					                                propertyNullability == null || propertyNullability[i], currentDepth,
					                                componentType.GetCascadeStyle(i));

					AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType);
				}
				else if (types[i].IsComponentType)
				{
					string subpath = SubPath(path, propertyNames[i]);

					WalkComponentTree((IAbstractComponentType) types[i], begin, alias, subpath, currentDepth, associationTypeSQLInfo);
				}
				begin += types[i].GetColumnSpan(Factory);
			}
		}
Exemple #7
0
		/// <summary>
		/// For a component, add to a list of associations to be fetched by outerjoin
		/// </summary>
		private void WalkComponentTree(IAbstractComponentType componentType, int propertyNumber, int begin,
			IOuterJoinLoadable persister, string alias, string path, int currentDepth)
		{
			IType[] types = componentType.Subtypes;
			string[] propertyNames = componentType.PropertyNames;
			for (int i = 0; i < types.Length; i++)
			{
				if (types[i].IsAssociationType)
				{
					IAssociationType associationType = (IAssociationType)types[i];
					string[] aliasedLhsColumns =
						JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, begin, persister, Factory);

					string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, begin, persister, Factory);
					string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister);

					string subpath = SubPath(path, propertyNames[i]);
					bool[] propertyNullability = componentType.PropertyNullability;

					JoinType joinType =
						GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns,
												propertyNullability == null || propertyNullability[i], currentDepth, componentType.GetCascadeStyle(i));

					AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType);
				}
				else if (types[i].IsComponentType)
				{
					string subpath = SubPath(path, propertyNames[i]);

					WalkComponentTree((IAbstractComponentType)types[i], propertyNumber, begin, persister, alias, subpath, currentDepth);
				}
				begin += types[i].GetColumnSpan(Factory);
			}
		}
Exemple #8
0
		private void CascadeComponent(object child, IAbstractComponentType componentType, object anything)
		{
			object[] children = componentType.GetPropertyValues(child, eventSource);
			IType[] types = componentType.Subtypes;
			for (int i = 0; i < types.Length; i++)
			{
				CascadeStyle componentPropertyStyle = componentType.GetCascadeStyle(i);
				if (componentPropertyStyle.DoCascade(action))
				{
					CascadeProperty(children[i], types[i], componentPropertyStyle, anything, false);
				}
			}
		}
Exemple #9
0
		private void CascadeComponent(object parent, object child, IAbstractComponentType componentType, string componentPropertyName, object anything)
		{
			componentPathStack.Push(componentPropertyName);
			object[] children = componentType.GetPropertyValues(child, eventSource);
			IType[] types = componentType.Subtypes;
			for (int i = 0; i < types.Length; i++)
			{
				CascadeStyle componentPropertyStyle = componentType.GetCascadeStyle(i);
				string subPropertyName = componentType.PropertyNames[i];
				if (componentPropertyStyle.DoCascade(action))
				{
					CascadeProperty(parent, children[i], types[i], componentPropertyStyle, subPropertyName, anything, false);
				}
			}
			componentPathStack.Pop();
		}