private SqlSelect VisitDefaultIfEmpty(Expression sequence) { SqlSelect select = this.VisitSequence(sequence); SqlAlias alias = new SqlAlias(select); SqlAliasRef aliasRef = new SqlAliasRef(alias); SqlExpression opt = new SqlOptionalValue( new SqlColumn( "test", _nodeFactory.Unary(SqlNodeType.OuterJoinedValue, _nodeFactory.Value(typeof(int?), _typeProvider.From(typeof(int)), 1, false, _dominatingExpression) ) ), _nodeFactory.Unary(SqlNodeType.OuterJoinedValue, aliasRef) ); SqlSelect optSelect = new SqlSelect(opt, alias, _dominatingExpression); alias = new SqlAlias(optSelect); aliasRef = new SqlAliasRef(alias); SqlExpression litNull = _nodeFactory.TypedLiteralNull(typeof(string), _dominatingExpression); SqlSelect selNull = new SqlSelect(litNull, null, _dominatingExpression); SqlAlias aliasNull = new SqlAlias(selNull); SqlJoin join = new SqlJoin(SqlJoinType.OuterApply, aliasNull, alias, null, _dominatingExpression); return new SqlSelect(aliasRef, join, _dominatingExpression); }
internal virtual SqlExpression VisitOptionalValue(SqlOptionalValue sov) { sov.HasValue = this.VisitExpression(sov.HasValue); sov.Value = this.VisitExpression(sov.Value); return sov; }
private Type GenerateOptionalValue(SqlOptionalValue opt) { Diagnostics.Debug.Assert(opt.HasValue.ClrType == typeof(int?)); Label labIsNull = gen.DefineLabel(); Label labExit = gen.DefineLabel(); Type actualType = this.Generate(opt.HasValue); Diagnostics.Debug.Assert(TypeSystem.IsNullableType(actualType)); LocalBuilder loc = gen.DeclareLocal(actualType); gen.Emit(OpCodes.Stloc, loc); gen.Emit(OpCodes.Ldloca, loc); this.GenerateHasValue(actualType); gen.Emit(OpCodes.Brfalse, labIsNull); this.GenerateExpressionForType(opt.Value, opt.ClrType); gen.Emit(OpCodes.Br_S, labExit); gen.MarkLabel(labIsNull); this.GenerateConstant(opt.ClrType, null); gen.MarkLabel(labExit); return opt.ClrType; }
internal override SqlExpression VisitOptionalValue(SqlOptionalValue sov) { if(_isDebugMode) { _commandStringBuilder.Append("opt("); this.Visit(sov.HasValue); _commandStringBuilder.Append(", "); this.Visit(sov.Value); _commandStringBuilder.Append(")"); return sov; } else { throw Error.InvalidFormatNode("OptionalValue"); } }
internal override SqlExpression VisitOptionalValue(SqlOptionalValue sov) { SqlExpression hasValue = this.VisitExpression(sov.HasValue); SqlExpression value = this.VisitExpression(sov.Value); return new SqlOptionalValue(hasValue, value); }
internal override SqlExpression VisitOptionalValue(SqlOptionalValue sov) { sov.HasValue = this.VisitNamedExpression(sov.HasValue, "test"); sov.Value = this.VisitExpression(sov.Value); return sov; }
internal override SqlExpression VisitOptionalValue(SqlOptionalValue sov) { bool saveCanJoin = this.canJoin; this.canJoin = false; try { return base.VisitOptionalValue(sov); } finally { this.canJoin = saveCanJoin; } }