ParamValue.Input(string name, object value, Type dataType) 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(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 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 Example2()
{
object data1 = 1;
var param = ParamValue.Input("deptId", data1, typeof(int));
// 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>("deptId"));
sqlBuilder.Select("budget")
.From("Department")
.Where("departmentid", "@deptId");
// 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 = deptId
ParamValue.Value = 1
ParamValue.Direction = Input
Budget = 220000.0000
*/
}
}
}
Applies to
.NET Standard
2.x