private void PrepareForIndex( QueryTranslator q ) { IQueryableCollection collPersister = q.GetCollectionPersister( collectionRole ); if( !collPersister.HasIndex ) { throw new QueryException( "unindexed collection before []" ); } string[ ] indexCols = collPersister.IndexColumnNames; if( indexCols.Length != 1 ) { throw new QueryException( "composite-index appears in []: " + path ); } string[ ] keyCols = collPersister.KeyColumnNames; JoinFragment ojf = q.CreateJoinFragment( useThetaStyleJoin ); ojf.AddCrossJoin( collPersister.TableName, collectionName ); ojf.AddFromFragmentString( join.ToFromFragmentString ); if( collPersister.IsOneToMany ) { IQueryable persister = (IQueryable) collPersister.ElementPersister; ojf.AddJoins( ( (IJoinable) persister).FromJoinFragment( collectionName, true, false ), ( (IJoinable) persister).WhereJoinFragment( collectionName, true, false ) ); } if( !continuation ) { AddJoin( collPersister.TableName, collectionName, keyCols ); } join.AddCondition( collectionName, indexCols, " = " ); string[ ] eltCols = collPersister.ElementColumnNames; CollectionElement elem = new CollectionElement(); elem.ElementColumns = StringHelper.Qualify( collectionName, eltCols ); elem.Type = collPersister.ElementType; elem.IsOneToMany = collPersister.IsOneToMany; elem.Alias = collectionName; elem.Join = join; collectionElements.Add( elem ); //addlast SetExpectingCollectionIndex(); q.AddCollection( collectionName, collectionRole ); q.AddJoin( collectionName, ojf ); }
/// <summary> /// /// </summary> /// <param name="q"></param> public void AddAssociation( QueryTranslator q ) { q.AddJoin( Name, join ); }
private void AddJoin( JoinFragment ojf, QueryTranslator q ) { JoinFragment fromClause = q.CreateJoinFragment( true ); fromClause.AddJoins( ojf.ToFromFragmentString, new SqlString( String.Empty ) ); q.AddJoin( pathExpressionParser.Name, fromClause ); //TODO: HACK with ToString() AddToCurrentJoin( ojf.ToWhereFragmentString.ToString() ); }