ParamValue.InputOutput<TType>(string name, TType value) Method
.NET Standard 2.x
Creates a new ParamValue
object as the input and output parameter of a stored procedure.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ParamValue InputOutput<TType>(string name, TType value)
Type Parameters
TType
The datatype of the parameter value.
Parameters
name
System.String
The name of the parameter.
value
TType
The value of the parameter.
Returns
Returns a newly created ParamValue
object.
Examples
The following code example creates a ParamValue
object and specifies its name and value. The direction is InputOutput.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Appeon.ApiDoc;
using SnapObjects.Data;
namespace Appeon.ApiDoc.ParamValueExamples
{
public class InputOutputExample
{
private readonly SchoolContext _context;
public InputOutputExample(SchoolContext context)
{
_context = context;
}
public async void Example2()
{
// Specifies the procedure to be executed.
string procedureName = "InputOutputTest";
ParamValue Param = ParamValue.Input<int>("id", 4);
ParamValue nameParam = ParamValue.InputOutput("name", "test", typeof(string));
// Gets and shows the attribute value of the ParamValue object
Console.WriteLine("ParamValue.Name = {0}", nameParam.Name);
Console.WriteLine("ParamValue.Direction = {0}\n", nameParam.Direction);
Console.WriteLine("Before Executes the SQL statement:");
Console.WriteLine("ParamValue.Value = {0}\n", nameParam.Value);
// Asynchronously Executes the SQL statement and gets the department by
// nameParam.
int rowAffected = await _context.SqlExecutor.ExecuteProcedureAsync(
procedureName, Param, nameParam);
Console.WriteLine("After Executes the SQL statement:");
Console.WriteLine("ParamValue.Value = {0}", nameParam.Value);
/*This code produces the following output:
ParamValue.Name = name
ParamValue.Direction = InputOutput
Before Executes the SQL statement:
ParamValue.Value = test
After Executes the SQL statement:
ParamValue.Value = Mathematics
*/
}
}
}
Applies to
.NET Standard
2.x