ParamValue.Input<TType>(string name, TType value) Method
.NET Standard 2.x
Creates a new ParamValue
object as the input parameter of a stored procedure or function.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public static ParamValue Input<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 Input.
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 InputExample
{
private readonly SchoolContext _context;
public InputExample(SchoolContext context)
{
_context = context;
}
public async void Example1()
{
string data1 = "Economics";
var param = ParamValue.Input("deptName", data1);
// Gets and shows the attribute value of the ParamValue object
Console.WriteLine("ParamValue.Name = {0}", param.Name);
Console.WriteLine("ParamValue.Value = {0}", param.Value);
Console.WriteLine("ParamValue.Direction = {0}", param.Direction);
// Defines a SqlQueryBuilder object
var sqlBuilder = new SqlQueryBuilder();
sqlBuilder.AddParameters(
SqlBuilder.Parameter<string>("deptName"));
sqlBuilder.Select("budget")
.From("Department")
.Where("name", "@deptName");
// Passes it the ParamValue object when querying data.
var result = await _context.SqlExecutor.ScalarAsync<string>(sqlBuilder, param);
Console.WriteLine("Budget = {0}", result);
/*This code produces the following output:
ParamValue.Name = deptName
ParamValue.Value = Economics
ParamValue.Direction = Input
Budget = 200000.0000
*/
}
}
}
Applies to
.NET Standard
2.x