ParamValue.InputOutput(string name, object value, Type dataType) 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(string name, object value, Type dataType)
Parameters
name
System.String
The name of the parameter.
value
System.Object
The value of the parameter.
dataType
Type
The type 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 Example1()
{
// Specifies the procedure to be executed.
string procedureName = "InputOutputTest";
ParamValue Param = ParamValue.Input<int>("id", 4);
ParamValue nameParam = ParamValue.InputOutput<string>("name", "test");
// 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