SqlContext.Parms Property
.NET Standard 2.x
Gets the parameter list of SqlContext.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public ParamValue[] Parms => _dynamicParmSet.Parms;
Property Value
Returns the parameter list of SqlContext.
Examples
The following code example demonstrates how to use the Parms
property to get the parameters defined in the SqlContext
object.
using System;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.SqlContextExamples
{
public class ParmsExample
{
private readonly SchoolContext _context;
public ParmsExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Defines the SQL SELECT statement.
var sql = @"select EnrollmentID, Grade from StudentGrade " +
"where StudentID = @StudentID and CourseID=@CourseID";
// Creates the SqlContext object.
var sqlContext = _context.CreateSqlContext(sql);
// Defines two parameters for the SQL statement.
sqlContext.SetParm(0, 2);
sqlContext.SetParm(1, 2021);
// Shows the parameters stored in the Parms property
Console.WriteLine($"Parameter count = {sqlContext.Parms.Length}, " +
$"Value of first parameter = {sqlContext.Parms[0].Value}, " +
$"Value of second parameter = {sqlContext.Parms[1].Value}.");
/*This code produces the following output:
Parameter count = 2, Value of first parameter = 2, Value of second parameter = 2021.
*/
}
}
}
Applies to
.NET Standard
2.x