DwProcedureAttribute Class
.NET Standard 2.x
Defines the information of the stored procedure used in the model.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Inheritance Constructor
System.Attribute
Syntax
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class DwProcedureAttribute : Attribute
Constructors
Name | Description |
---|---|
DwProcedureAttribute(string procedure) | Initializes a new instance of the DwProcedureAttribute class. |
Properties
Name | Return Type | Description |
---|---|---|
Parameters | string | Gets or sets the parameters used by the stored procedure. |
Procedure | string | Gets the information of the stored procedure. |
Examples
The following code example demonstrates how to use the Model DwProcedure attribute. The example defines the DwProcedure attribute in the Model, which means the data source is from the stored procedure. The stored procedure GetStudentGrades will get data from the StudentGrade table according to StudentID.
Model: D_Getstudentgrades
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using SnapObjects.Data;
using DWNet.Data;
using Newtonsoft.Json;
using System.Collections;
namespace Appeon.ApiDoc.Models
{
[DataWindow("d_getstudentgrades", DwStyle.Grid)]
[DwProcedure("dbo.GetStudentGrades", Parameters = ":StudentID")]
[DwParameter("StudentID", typeof(decimal?))]
public class D_Getstudentgrades
{
[DwColumn("EnrollmentID")]
public int? Enrollmentid { get; set; }
[DwColumn("Grade")]
public decimal? Grade { get; set; }
[DwColumn("CourseID")]
public int? Courseid { get; set; }
[DwColumn("StudentID")]
public int? Studentid { get; set; }
}
}
Example Method:
using System;
using DWNet.Data;
namespace Appeon.ApiDoc.DwProcedureAttributeExamples
{
public class DwProcedureAttributeExample
{
private readonly SchoolContext _context;
public DwProcedureAttributeExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
var datastore = new DataStore("D_Getstudentgrades", _context);
datastore.Retrieve(2);
Console.WriteLine($"datastore RowCount={datastore.RowCount}.");
/* This code example produces the following output:
datastore RowCount=2.
*/
/* The following SQL is generated:
exec sp_executesql N'execute dbo.GetStudentGrades @StudentID',N'@StudentID decimal(1,0)',@StudentID=2
*/
}
}
}
Example Refer To
DataWindow File: d_getstudentgrades
Applies to
.NET Standard
2.x