ParamValue.ReturnValue(string name, Type dataType) Method
.NET Standard 2.x
Creates a new ParamValue
object as the return value of a stored procedure.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ParamValue ReturnValue(string name, Type dataType)
Parameters
name
System.String
The name of the return value.
dataType
Type
The type of the return value.
Returns
Returns a newly created ParamValue
object.
Examples
The following code Creates a new ParamValue
object as the return value of a stored procedure.
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 ReturnValueExample
{
private readonly SchoolContext _context;
public ReturnValueExample(SchoolContext context)
{
_context = context;
}
public async void Example2()
{
// Specifies the procedure to be executed.
string procedureName = "GetDepartmentName";
ParamValue idParam = ParamValue.Input<string>("id", "4");
ParamValue nameParam = ParamValue.Output<string>("name");
// The parameter 'Name' is ReturnValue type.
ParamValue returnParam = ParamValue.ReturnValue("name", typeof(string));
// Gets and shows the attribute value of the ParamValue object
Console.WriteLine("returnParam.Name = {0}", returnParam.Name);
Console.WriteLine("returnParam.Direction = {0}\n", returnParam.Direction);
Console.WriteLine("Before Executes the SQL statement:");
Console.WriteLine("returnParam.Value = {0}\n", returnParam.Value);
// Asynchronously Executes the SQL statement and gets the department by
// nameParam.
int rowAffected = await _context.SqlExecutor.ExecuteProcedureAsync(
procedureName, idParam, nameParam, returnParam);
Console.WriteLine("After Executes the SQL statement:");
Console.WriteLine("returnParam.Value = {0}", returnParam.Value);
/*This code produces the following output:
returnParam.Name = name
returnParam.Direction = ReturnValue
Before Executes the SQL statement:
returnParam.Value =
After Executes the SQL statement:
returnParam.Value = Economics
*/
}
}
}
Applies to
.NET Standard
2.x