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()); }
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); }
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); } JoinSequence fromJoins = new JoinSequence(q.Factory) .SetUseThetaStyle(useThetaStyleJoin) .SetRoot(collPersister, collectionName) .SetNext(joinSequence.Copy()); if (!continuation) { AddJoin(collectionName, collPersister.CollectionType); } joinSequence.AddCondition(new SqlString(collectionName + '.' + indexCols[0] + " = ")); CollectionElement elem = new CollectionElement(); elem.ElementColumns = collPersister.GetElementColumnNames(collectionName); elem.Type = collPersister.ElementType; elem.IsOneToMany = collPersister.IsOneToMany; elem.Alias = collectionName; elem.JoinSequence = joinSequence; collectionElements.Add(elem); //addlast SetExpectingCollectionIndex(); q.AddCollection(collectionName, collectionRole); q.AddJoin(collectionName, fromJoins); }
/// <summary> /// /// </summary> /// <param name="q"></param> public void AddAssociation(QueryTranslator q) { q.AddJoin(Name, joinSequence); }