/// <summary> /// /// </summary> /// <param name="q"></param> /// <returns></returns> public string AddFromCollection( QueryTranslator q ) { IType collectionElementType = PropertyType; if( collectionElementType == null ) { throw new QueryException( string.Format( "must specify 'elements' for collection valued property in from clause: {0}", path ) ); } if( collectionElementType.IsEntityType ) { // an association IQueryableCollection collectionPersister = q.GetCollectionPersister( collectionRole ); IQueryable entityPersister = (IQueryable) collectionPersister.ElementPersister; System.Type clazz = entityPersister.MappedClass; string[] collectionElementColumns = CurrentColumns(); string elementName; if ( collectionPersister.IsOneToMany ) { elementName = collectionName; // allow index() function q.DecoratePropertyMapping( elementName, collectionPersister ); } else { // many to many q.AddCollection( collectionName, collectionRole ); elementName = q.CreateNameFor( clazz ); string[] keyColumnNames = entityPersister.IdentifierColumnNames; join.AddJoin( entityPersister.TableName, elementName, collectionElementColumns, keyColumnNames, joinType ); } q.AddFrom( elementName, clazz, join ); currentPropertyMapping = new CollectionPropertyMapping( collectionPersister ); return elementName; } else { // collection of values q.AddFromCollection( collectionName, collectionRole, join ); return collectionName; } }