DbResultSet.GetDataType(string columnName) Method
.NET Standard 2.x
Gets the data type in .NET for the specified column in the result set.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public abstract Type GetDataType(string columnName);
Parameters
columnName System.String
The name of the column.
Returns
System.Type
Returns the data type in .NET.
Examples
The following code example demonstrates how to use the GetDataType method to get the data type of the Grade column in the DbResultSet object.
using System;
using SnapObjects.Data;
using PowerScript.Bridge;
namespace Appeon.ApiDoc.DbResultSetExamples
{
public class GetDataTypeExample
{
private readonly SchoolContext _context;
public GetDataTypeExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example2()
{
int studentID = 2;
// Executes a stored procedure which gets the data of StudentGrade table according to StudentID.
_context.SqlExecutor.ExecuteProcedure("GetStudentGrades",
out DbResultSet resultSet, ParamValue.New<int>("StudentID", studentID));
resultSet.Next();
if (resultSet.SqlCode == 0)
{
// Gets the data type of the Grade column
var type = resultSet.GetDataType("Grade");
// If the data type is decimal?, show the value
if (type == typeof(decimal?))
{
decimal? Grade = resultSet.GetValue<decimal?>("Grade");
Console.WriteLine($"Grade = {Grade}");
}
}
resultSet.Close();
/*This code produces the following output:
Grade = 4.00
*/
}
}
}
Applies to
.NET Standard
2.x