コード例 #1
0
		public IList GenerateCustomReturns(bool queryHadAliases)
		{
			IList customReturns = new List<object>();
			IDictionary<string, object> customReturnsByAlias = new Dictionary<string, object>();
			for (int i = 0; i < queryReturns.Length; i++)
			{
				if (queryReturns[i] is NativeSQLQueryScalarReturn)
				{
					NativeSQLQueryScalarReturn rtn = (NativeSQLQueryScalarReturn) queryReturns[i];
					customReturns.Add(new ScalarReturn(rtn.Type, rtn.ColumnAlias));
				}
				else if (queryReturns[i] is NativeSQLQueryRootReturn)
				{
					NativeSQLQueryRootReturn rtn = (NativeSQLQueryRootReturn) queryReturns[i];
					string alias = rtn.Alias;
					IEntityAliases entityAliases;
					if (queryHadAliases || HasPropertyResultMap(alias))
					{
						entityAliases =
							new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
					}
					else
					{
						entityAliases =
							new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
					}
					RootReturn customReturn = new RootReturn(alias, rtn.ReturnEntityName, entityAliases, rtn.LockMode);
					customReturns.Add(customReturn);
					customReturnsByAlias[rtn.Alias] = customReturn;
				}
				else if (queryReturns[i] is NativeSQLQueryCollectionReturn)
				{
					NativeSQLQueryCollectionReturn rtn = (NativeSQLQueryCollectionReturn) queryReturns[i];
					string alias = rtn.Alias;
					ISqlLoadableCollection persister = alias2CollectionPersister[alias];
					bool isEntityElements = persister.ElementType.IsEntityType;
					ICollectionAliases collectionAliases;
					IEntityAliases elementEntityAliases = null;
					if (queryHadAliases || HasPropertyResultMap(alias))
					{
						collectionAliases =
							new GeneratedCollectionAliases(collectionPropertyResultMaps[alias], alias2CollectionPersister[alias],
														   alias2CollectionSuffix[alias]);
						if (isEntityElements)
						{
							elementEntityAliases =
								new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
						}
					}
					else
					{
						collectionAliases =
							new ColumnCollectionAliases(collectionPropertyResultMaps[alias], alias2CollectionPersister[alias]);
						if (isEntityElements)
						{
							elementEntityAliases =
								new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
						}
					}
					CollectionReturn customReturn =
						new CollectionReturn(alias, rtn.OwnerEntityName, rtn.OwnerProperty, collectionAliases, elementEntityAliases,
											 rtn.LockMode);
					customReturns.Add(customReturn);
					customReturnsByAlias[rtn.Alias] = customReturn;
				}
				else if (queryReturns[i] is NativeSQLQueryJoinReturn)
				{
					NativeSQLQueryJoinReturn rtn = (NativeSQLQueryJoinReturn) queryReturns[i];
					string alias = rtn.Alias;
					FetchReturn customReturn;
					NonScalarReturn ownerCustomReturn = (NonScalarReturn) customReturnsByAlias[rtn.OwnerAlias];
					ISqlLoadableCollection persister;
					if (alias2CollectionPersister.TryGetValue(alias, out persister))
					{
						bool isEntityElements = persister.ElementType.IsEntityType;
						ICollectionAliases collectionAliases;
						IEntityAliases elementEntityAliases = null;
						if (queryHadAliases || HasPropertyResultMap(alias))
						{
							collectionAliases =
								new GeneratedCollectionAliases(collectionPropertyResultMaps[alias], persister, alias2CollectionSuffix[alias]);
							if (isEntityElements)
							{
								elementEntityAliases =
									new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
							}
						}
						else
						{
							collectionAliases = new ColumnCollectionAliases(collectionPropertyResultMaps[alias], persister);
							if (isEntityElements)
							{
								elementEntityAliases =
									new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
							}
						}
						customReturn =
							new CollectionFetchReturn(alias, ownerCustomReturn, rtn.OwnerProperty, collectionAliases, elementEntityAliases,
													  rtn.LockMode);
					}
					else 
					{
						IEntityAliases entityAliases;
						if (queryHadAliases || HasPropertyResultMap(alias))
						{
							entityAliases =
								new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
						}
						else
						{
							entityAliases =
								new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
						}
						customReturn = new EntityFetchReturn(alias, entityAliases, ownerCustomReturn, rtn.OwnerProperty, rtn.LockMode);
					}
					customReturns.Add(customReturn);
					customReturnsByAlias[alias] = customReturn;
				}
			}
			return customReturns;
		}
コード例 #2
0
        public IList GenerateCustomReturns(bool queryHadAliases)
        {
            IList customReturns = new List <object>();
            IDictionary <string, object> customReturnsByAlias = new Dictionary <string, object>();

            for (int i = 0; i < queryReturns.Length; i++)
            {
                if (queryReturns[i] is NativeSQLQueryScalarReturn)
                {
                    NativeSQLQueryScalarReturn rtn = (NativeSQLQueryScalarReturn)queryReturns[i];
                    customReturns.Add(new ScalarReturn(rtn.Type, rtn.ColumnAlias));
                }
                else if (queryReturns[i] is NativeSQLQueryRootReturn)
                {
                    NativeSQLQueryRootReturn rtn = (NativeSQLQueryRootReturn)queryReturns[i];
                    string         alias         = rtn.Alias;
                    IEntityAliases entityAliases;
                    if (queryHadAliases || HasPropertyResultMap(alias))
                    {
                        entityAliases =
                            new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                    }
                    else
                    {
                        entityAliases =
                            new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                    }
                    RootReturn customReturn = new RootReturn(alias, rtn.ReturnEntityName, entityAliases, rtn.LockMode);
                    customReturns.Add(customReturn);
                    customReturnsByAlias[rtn.Alias] = customReturn;
                }
                else if (queryReturns[i] is NativeSQLQueryCollectionReturn)
                {
                    NativeSQLQueryCollectionReturn rtn = (NativeSQLQueryCollectionReturn)queryReturns[i];
                    string alias = rtn.Alias;
                    ISqlLoadableCollection persister = alias2CollectionPersister[alias];
                    bool isEntityElements            = persister.ElementType.IsEntityType;
                    ICollectionAliases collectionAliases;
                    IEntityAliases     elementEntityAliases = null;
                    if (queryHadAliases || HasPropertyResultMap(alias))
                    {
                        collectionAliases =
                            new GeneratedCollectionAliases(collectionPropertyResultMaps[alias], alias2CollectionPersister[alias],
                                                           alias2CollectionSuffix[alias]);
                        if (isEntityElements)
                        {
                            elementEntityAliases =
                                new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                        }
                    }
                    else
                    {
                        collectionAliases =
                            new ColumnCollectionAliases(collectionPropertyResultMaps[alias], alias2CollectionPersister[alias]);
                        if (isEntityElements)
                        {
                            elementEntityAliases =
                                new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                        }
                    }
                    CollectionReturn customReturn =
                        new CollectionReturn(alias, rtn.OwnerEntityName, rtn.OwnerProperty, collectionAliases, elementEntityAliases,
                                             rtn.LockMode);
                    customReturns.Add(customReturn);
                    customReturnsByAlias[rtn.Alias] = customReturn;
                }
                else if (queryReturns[i] is NativeSQLQueryJoinReturn)
                {
                    NativeSQLQueryJoinReturn rtn = (NativeSQLQueryJoinReturn)queryReturns[i];
                    string                 alias = rtn.Alias;
                    FetchReturn            customReturn;
                    NonScalarReturn        ownerCustomReturn = (NonScalarReturn)customReturnsByAlias[rtn.OwnerAlias];
                    ISqlLoadableCollection persister;
                    if (alias2CollectionPersister.TryGetValue(alias, out persister))
                    {
                        bool isEntityElements = persister.ElementType.IsEntityType;
                        ICollectionAliases collectionAliases;
                        IEntityAliases     elementEntityAliases = null;
                        if (queryHadAliases || HasPropertyResultMap(alias))
                        {
                            collectionAliases =
                                new GeneratedCollectionAliases(collectionPropertyResultMaps[alias], persister, alias2CollectionSuffix[alias]);
                            if (isEntityElements)
                            {
                                elementEntityAliases =
                                    new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                            }
                        }
                        else
                        {
                            collectionAliases = new ColumnCollectionAliases(collectionPropertyResultMaps[alias], persister);
                            if (isEntityElements)
                            {
                                elementEntityAliases =
                                    new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                            }
                        }
                        customReturn =
                            new CollectionFetchReturn(alias, ownerCustomReturn, rtn.OwnerProperty, collectionAliases, elementEntityAliases,
                                                      rtn.LockMode);
                    }
                    else
                    {
                        IEntityAliases entityAliases;
                        if (queryHadAliases || HasPropertyResultMap(alias))
                        {
                            entityAliases =
                                new DefaultEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                        }
                        else
                        {
                            entityAliases =
                                new ColumnEntityAliases(entityPropertyResultMaps[alias], alias2Persister[alias], alias2Suffix[alias]);
                        }
                        customReturn = new EntityFetchReturn(alias, entityAliases, ownerCustomReturn, rtn.OwnerProperty, rtn.LockMode);
                    }
                    customReturns.Add(customReturn);
                    customReturnsByAlias[alias] = customReturn;
                }
            }
            return(customReturns);
        }