IDataStoreBase.GetRowIdFromRow(int rownumber, DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Gets the unique row identifier of a row in the DataStore from the row number associated with that row.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public int GetRowIdFromRow(int rownumber, DwBuffer bufferType = DwBuffer.Primary);
Parameters
rownumber
System.Int32
The zero-based row number from the specified buffer.
bufferType
DWNet.Data.DwBuffer
The buffer of the DataStore. The default is DwBuffer.Primary
.
Returns
System.Int32
Returns the row identifier in buffer. Returns -1
if the row identifier is not in the current buffer.
Remarks
The row identifier value is not the same as the row number value used in many DataStore method calls and should not be used for the row number value. Instead you should first convert the unique row identifier into a row number by calling the GetRowFromRowId
method.
Examples
The following code example demonstrates how to get the unique row identifier according to the row number.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class GetRowIdFromRowExample
{
private readonly SchoolContext _context;
public GetRowIdFromRowExample(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 row whose RowId=0
// The row whose RowId=0 does not necessarily mean the first row.
var department = datastore.GetModelByRowId<D_Department>(0);
Console.WriteLine(
"Rowid=0, Department ID: {0}; Department Name: {1}",
department.Departmentid,
department.Name);
// Gets the value of RowId for the first row
int rowid = datastore.GetRowIdFromRow(0, DwBuffer.Primary);
Console.WriteLine("When Row=0, Rowid={0}", rowid);
// Gets the data of the first row according to its RowId
department = datastore.GetModelByRowId<D_Department>(rowid);
Console.WriteLine(
"Row=0, Department ID: {0}; Department Name: {1}",
department.Departmentid,
department.Name);
/*This code produces the following output:
Rowid=0, Department ID: 1; Department Name: Engineering
When Row=0, Rowid=3
Row=0, Department ID: 7; Department Name: Mathematics
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x