IDataStore<TModel>. GetModel(int row, bool calcCompute = false) Method
.NET Standard 2.x
Obtains the TModel object according to the specified row.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
TModel GetModel(int row, bool calcCompute = false);
Parameters
row System.Int32
The zero-based row number to get data.
calcCompute System.Boolean
Whether to calculate columns with DwCompute attribute.
Returns
TModel
Returns the TModel object which contains the data of the row.
Remarks
This method makes a deep copy of the data, therefore, any changes made to this TModel will not affect the data source. To make a shallow copy of the data, refer to GetForUpdate.
Examples
The following code example demonstrates how to get data according to the row number.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStore_GenericExamples
{
public class GetModelExample
{
private readonly SchoolContext _context;
public GetModelExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore<D_Department>(_context);
datastore.Retrieve();
var department = datastore.GetModel(0);
Console.WriteLine("Department ID: {0},Department Name: {1}",
department.Departmentid, department.Name);
/*This code produces the following output:
Department ID: 1;
Department Name: Engineering
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department