IDataStoreBase.GetRowFromRowId(int rowid, DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Gets the row number of a row in the DataStore from the unique row identifier associated with that row.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public int GetRowFromRowId(int rowid, DwBuffer bufferType = DwBuffer.Primary);
Parameters
rowid
System.Int32
A number specifying the row identifier for which you want to get the associated row number.
bufferType
DWNet.Data.DwBuffer
A value of the DwBuffer
enumerated datatype identifying the DataWindow buffer
that contains the row.
Returns
System.Int32
Returns the row number in the buffer. Returns -1
if the row number is not in the current buffer.
Remarks
This method allows you to use a unique row identifier to retrieve the associated DataStore row number. The row identifier is not affected by operations (such as Insert, Delete, or Filter) that might change the original order (and consequently the row numbers) of the rows in the DataStore.
The row identifier is relative to the DataStore that currently owns the row.
Examples
The following code example demonstrates how to get the row number according to the unique row identifier.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class GetRowFromRowIdExample
{
private readonly SchoolContext _context;
public GetRowFromRowIdExample(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();
// Sorts data by departmentid in descending order
datastore.SetSort("departmentid desc");
datastore.Sort();
// Gets the data of the first row
var department = datastore.GetModel<D_Department>(0);
Console.WriteLine(
"Row = 0, Department ID: {0}; Department Name: {1}",
department.Departmentid,
department.Name);
// Gets the row number where RowId=0
int row = datastore.GetRowFromRowId(0, DwBuffer.Primary);
Console.WriteLine("When Rowid = 0, Row = {0}", row);
// Gets the data of the row whose RowId=0
department = datastore.GetModel<D_Department>(row);
Console.WriteLine(
"Rowid = 0, Department ID: {0}; Department Name: {1}",
department.Departmentid,
department.Name);
/*This code produces the following output:
Row = 0, Department ID: 7; Department Name: Mathematics
When Rowid = 0, Row = 3
Rowid = 0, Department ID: 1; Department Name: Engineering
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x