internal override DbExpression AsCqt(DbExpression row, bool skipIsNotNull) { DbExpression cqt = this.RestrictedMemberSlot.MemberPath.AsCqt(row); if (Helper.IsRefType((GlobalItem)this.RestrictedMemberSlot.MemberPath.EdmType)) { cqt = (DbExpression)cqt.Deref(); } if (this.Domain.Count == 1) { cqt = (DbExpression)cqt.IsOfOnly(TypeUsage.Create(((TypeConstant)this.Domain.Values.Single <Constant>()).EdmType)); } else { cqt = Helpers.BuildBalancedTreeInPlace <DbExpression>((IList <DbExpression>) this.Domain.Values.Select <Constant, DbExpression>((Func <Constant, DbExpression>)(t => (DbExpression)cqt.IsOfOnly(TypeUsage.Create(((TypeConstant)t).EdmType)))).ToList <DbExpression>(), (Func <DbExpression, DbExpression, DbExpression>)((prev, next) => (DbExpression)prev.Or(next))); } return(cqt); }
internal override DbExpression AsCqt(DbExpression row, bool skipIsNotNull) { DbExpression cqt = this.RestrictedMemberSlot.MemberPath.AsCqt(row); if (Helper.IsRefType(this.RestrictedMemberSlot.MemberPath.EdmType)) { cqt = cqt.Deref(); } if (this.Domain.Count == 1) { // Single value cqt = cqt.IsOfOnly(TypeUsage.Create(((TypeConstant)this.Domain.Values.Single()).EdmType)); } else { // Multiple values: build list of var IsOnOnly(t1), var = IsOnOnly(t1), ..., then OR them all. List <DbExpression> operands = this.Domain.Values.Select(t => (DbExpression)cqt.IsOfOnly(TypeUsage.Create(((TypeConstant)t).EdmType))).ToList(); cqt = Helpers.BuildBalancedTreeInPlace(operands, (prev, next) => prev.Or(next)); } return(cqt); }