protected override Expression VisitCollectionAccess(CollectionAccessExpression expr) { MemberNameVisitor visitor = new MemberNameVisitor(_rootCriteria, false); visitor.Visit(expr.Expression); visitor.CurrentCriteria.CreateCriteria(expr.Name, _alias, JoinType.LeftOuterJoin); return expr; }
protected virtual Expression VisitCollectionAccess(CollectionAccessExpression expr) { EntityExpression e = (EntityExpression)Visit(expr.Expression); if (e != expr.Expression) { return new CollectionAccessExpression(expr.Name, expr.Type, expr.NHibernateType, e, expr.ElementExpression); } return expr; }
private Expression CastIfNecessary(CollectionAccessExpression expr) { if (expr.Type.IsGenericType) return expr; MethodInfo method = typeof(Enumerable).GetMethod("Cast") .MakeGenericMethod(expr.ElementExpression.Type); return Expression.Call(method, expr); }
protected override Expression VisitCollectionAccess(CollectionAccessExpression expr) { EntityExpression elementExpression = expr.ElementExpression; if (elementExpression == null) return expr; string alias = FindCollectionAlias(elementExpression.Type); if (String.IsNullOrEmpty(alias)) return expr; elementExpression = new EntityExpression(elementExpression.AssociationPath, alias, elementExpression.Type, elementExpression.MetaData, elementExpression.Expression); return new CollectionAccessExpression(expr.Name, expr.Type, expr.NHibernateType, expr.Expression, elementExpression); }
protected override Expression VisitCollectionAccess(CollectionAccessExpression expr) { return VisitPropertyAccess(expr); }
protected override Expression VisitCollectionAccess(CollectionAccessExpression expr) { expr = (CollectionAccessExpression)base.VisitCollectionAccess(expr); //memberNameBuilder.Append(expr.Name + "."); ResetMemberName(expr.Name + "."); currentExpression = expr; if (createCriteriaForCollections) { if (expr.ElementExpression != null) { currentCriteria = EnsureCriteria(expr.Name, expr.ElementExpression.Alias); } } isQueringEntity = false; return expr; }
private ICriterion GetCollectionContainsCriteria(CollectionAccessExpression arg, Expression containsExpression) { EntityExpression rootEntity = EntityExpressionVisitor.FirstEntity(arg); var rootEntityType = rootEntity.Type; if (rootEntity.MetaData.HasProxy) { rootEntityType = rootEntity.MetaData.GetMappedClass(EntityMode.Poco); } DetachedCriteria query = DetachedCriteria.For(rootEntityType) .SetProjection(Projections.Id()); var visitor = new MemberNameVisitor(query.Adapt(session), true); visitor.Visit(arg); //TODO: this won't work for collections of values var containedEntity = QueryUtil.GetExpressionValue(containsExpression); var collectionIdPropertyName = visitor.MemberName + "." + arg.ElementExpression.MetaData.IdentifierPropertyName; var idValue = arg.ElementExpression.MetaData.GetIdentifier(containedEntity, EntityMode.Poco); query.Add(Restrictions.Eq(collectionIdPropertyName, idValue)); string identifierName = rootEntity.MetaData.IdentifierPropertyName; return Subqueries.PropertyIn(identifierName, query); }
protected override Expression VisitCollectionAccess(CollectionAccessExpression expr) { Type = BinaryCriterionType.Property; return expr; }