Example #1
0
        public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection)
        {
            string manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters);
            string condition        = string.Empty.Equals(manyToManyFilter)
                                                ? on
                                                : string.Empty.Equals(on) ? manyToManyFilter : on + " and " + manyToManyFilter;

            outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition);
            outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true),
                               joinable.WhereJoinFragment(rhsAlias, false, true));
        }
Example #2
0
        public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection)
        {
            string    manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters);
            SqlString condition        = string.Empty.Equals(manyToManyFilter)
                                                                ? on
                                                                : SqlStringHelper.IsEmpty(on) ? new SqlString(manyToManyFilter) :
                                         on.Append(" and ").Append(manyToManyFilter);

            outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition);
            outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true),
                               joinable.WhereJoinFragment(rhsAlias, false, true));
        }
Example #3
0
        private void InitStatementString(string alias, int batchSize, SqlString subquery)
        {
            int joins           = CountEntityPersisters(associations);
            int collectionJoins = CountCollectionPersisters(associations) + 1;

            Suffixes           = BasicLoader.GenerateSuffixes(joins);
            CollectionSuffixes = BasicLoader.GenerateSuffixes(joins, collectionJoins);

            SqlStringBuilder whereString = WhereString(alias, collectionPersister.KeyColumnNames, subquery, batchSize);

            string manyToManyOrderBy = string.Empty;
            string filter            = collectionPersister.FilterFragment(alias, EnabledFilters);

            if (collectionPersister.IsManyToMany)
            {
                // from the collection of associations, locate OJA for the
                // ManyToOne corresponding to this persister to fully
                // define the many-to-many; we need that OJA so that we can
                // use its alias here
                // TODO : is there a better way here?
                IAssociationType associationType = (IAssociationType)collectionPersister.ElementType;
                foreach (OuterJoinableAssociation oja in associations)
                {
                    if (oja.JoinableType == associationType)
                    {
                        // we found it
                        filter            += collectionPersister.GetManyToManyFilterFragment(oja.RHSAlias, EnabledFilters);
                        manyToManyOrderBy += collectionPersister.GetManyToManyOrderByString(oja.RHSAlias);
                    }
                }
            }

            whereString.Insert(0, StringHelper.MoveAndToBeginning(filter));
            JoinFragment ojf = MergeOuterJoins(associations);

            SqlSelectBuilder select =
                new SqlSelectBuilder(Factory)
                .SetSelectClause(collectionPersister.SelectFragment(alias, CollectionSuffixes[0])
                                 + SelectString(associations))
                .SetFromClause(collectionPersister.TableName, alias)
                .SetWhereClause(whereString.ToSqlString())
                .SetOuterJoins(ojf.ToFromFragmentString, ojf.ToWhereFragmentString);

            select.SetOrderByClause(OrderBy(associations, MergeOrderings(collectionPersister.GetSQLOrderByString(alias), manyToManyOrderBy)));

            if (Factory.Settings.IsCommentsEnabled)
            {
                select.SetComment("load collection " + collectionPersister.Role);
            }

            SqlString = select.ToSqlString();
        }
		public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection)
		{
			string manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters);
			SqlString condition = string.Empty.Equals(manyToManyFilter)
			                   	? on
			                   	: StringHelper.IsEmpty(on) ? new SqlString(manyToManyFilter) : 
									on.Append(" and ").Append(manyToManyFilter);

			outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition);
			outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true),
			                   joinable.WhereJoinFragment(rhsAlias, false, true));
		}
		public void AddManyToManyJoin(JoinFragment outerjoin, IQueryableCollection collection)
		{
			string manyToManyFilter = collection.GetManyToManyFilterFragment(rhsAlias, enabledFilters);
			string condition = string.Empty.Equals(manyToManyFilter)
			                   	? on
			                   	: string.Empty.Equals(on) ? manyToManyFilter : on + " and " + manyToManyFilter;

			outerjoin.AddJoin(joinable.TableName, rhsAlias, lhsColumns, rhsColumns, joinType, condition);
			outerjoin.AddJoins(joinable.FromJoinFragment(rhsAlias, false, true),
			                   joinable.WhereJoinFragment(rhsAlias, false, true));
		}