/// <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; string clazz = entityPersister.EntityName; 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); AddJoin(elementName, (IAssociationType) collectionElementType); } q.AddFrom(elementName, clazz, joinSequence); currentPropertyMapping = new CollectionPropertyMapping(collectionPersister); return elementName; } // collection of values q.AddFromCollection(collectionName, collectionRole, joinSequence); return collectionName; }
/// <summary> /// /// </summary> /// <param name="q"></param> /// <returns></returns> public string AddFromAssociation(QueryTranslator q) { if (IsCollectionValued) { return AddFromCollection(q); } q.AddFrom(currentName, joinSequence); return currentName; }