Ejemplo n.º 1
0
 public CollectionFetchReturn(string alias, NonScalarReturn owner, string ownerProperty,
                              ICollectionAliases collectionAliases, IEntityAliases elementEntityAliases,
                              LockMode lockMode) : base(owner, ownerProperty, alias, lockMode)
 {
     this.collectionAliases    = collectionAliases;
     this.elementEntityAliases = elementEntityAliases;
 }
Ejemplo n.º 2
0
		private static IEnumerable<IReturn> GenerateCustomReturns(IEnumerable<INativeSQLQueryReturn> queryReturns, bool queryHadAliases, SQLQueryContext context)
		{
			IDictionary<string, NonScalarReturn> customReturnsByAlias = new Dictionary<string, NonScalarReturn>();

			foreach (var nativeRtn in queryReturns)
			{
				var nativeScalarRtn = nativeRtn as NativeSQLQueryScalarReturn;
				if (nativeScalarRtn != null)
				{
					yield return new ScalarReturn(nativeScalarRtn.Type, nativeScalarRtn.ColumnAlias);
					continue;
				}

				var nativeJoinRtn = nativeRtn as NativeSQLQueryJoinReturn;
				if (nativeJoinRtn != null)
				{
					var owner = customReturnsByAlias[nativeJoinRtn.OwnerAlias];
					var fetchReturn = new NonScalarReturn(context, queryHadAliases, nativeJoinRtn.Alias, nativeJoinRtn.LockMode, owner);
					yield return customReturnsByAlias[fetchReturn.Alias] = fetchReturn;
					continue;
				}

				var nativeNonScalarRtn = nativeRtn as NativeSQLQueryNonScalarReturn;
				if (nativeNonScalarRtn != null)
				{
					var nonFetchReturn = new NonScalarReturn(context, queryHadAliases, nativeNonScalarRtn.Alias, nativeNonScalarRtn.LockMode);
					yield return customReturnsByAlias[nonFetchReturn.Alias] = nonFetchReturn;
				}
			}
		}
		public CollectionFetchReturn(string alias, NonScalarReturn owner, string ownerProperty,
		                             ICollectionAliases collectionAliases, IEntityAliases elementEntityAliases,
		                             LockMode lockMode) : base(owner, ownerProperty, alias, lockMode)
		{
			this.collectionAliases = collectionAliases;
			this.elementEntityAliases = elementEntityAliases;
		}
Ejemplo n.º 4
0
		public FetchReturn(NonScalarReturn owner, string ownerProperty, string alias, LockMode lockMode)
			: base(alias, lockMode)
		{
			this.owner = owner;
			this.ownerProperty = ownerProperty;
		}
        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);
        }
Ejemplo n.º 6
0
 public FetchReturn(NonScalarReturn owner, string ownerProperty, string alias, LockMode lockMode)
     : base(alias, lockMode)
 {
     this.owner         = owner;
     this.ownerProperty = ownerProperty;
 }
		public EntityFetchReturn(string alias, IEntityAliases entityAliases, NonScalarReturn owner, string ownerProperty,
		                         LockMode lockMode) : base(owner, ownerProperty, alias, lockMode)
		{
			this.entityAliases = entityAliases;
		}
Ejemplo n.º 8
0
 public EntityFetchReturn(string alias, IEntityAliases entityAliases, NonScalarReturn owner, string ownerProperty,
                          LockMode lockMode) : base(owner, ownerProperty, alias, lockMode)
 {
     this.entityAliases = entityAliases;
 }