public async Task ExecuteWithNamedArgs() { var name = ObjectName.Parse("a.func"); var info = new SqlMethodInfo(name); info.Parameters.Add(new SqlParameterInfo("a", PrimitiveTypes.Integer())); var procedure = new SqlProcedureDelegate(info, ctx => { var a = ctx.Value("a"); var b = a.Multiply(SqlObject.BigInt(2)); Console.Out.WriteLine("a * 2 = {0}", b); }); Assert.Equal(name, info.MethodName); var result = await procedure.ExecuteAsync(context, new InvokeArgument("a", SqlObject.Integer(22))); Assert.NotNull(result); Assert.False(result.HasReturnedValue); }
public async void ExecuteWithOutputArgs() { var name = ObjectName.Parse("a.proc"); var info = new SqlMethodInfo(name); info.Parameters.Add(new SqlParameterInfo("a", PrimitiveTypes.Integer())); info.Parameters.Add(new SqlParameterInfo("b", PrimitiveTypes.Integer(), SqlParameterDirection.Out)); var procedure = new SqlProcedureDelegate(info, ctx => { var a = ctx.Value("a"); var b = a.Multiply(SqlObject.Integer(2)); ctx.SetOutput("b", SqlExpression.Constant(b)); }); Assert.Equal(name, info.MethodName); var result = await procedure.ExecuteAsync(context, new InvokeArgument("a", SqlObject.Integer(22))); Assert.NotNull(result); Assert.False(result.HasReturnedValue); Assert.NotEmpty(result.Output); }