IDataStoreBase.ReselectRowAsync(int row) Method
.NET Standard 2.x
Asynchronously accesses the database to retrieve values for all columns that can be updated and refreshes all timestamp columns in a row in the DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public Task<int> ReselectRowAsync(int row)
Parameters
row
System.Int32
A zero-based index number of the row.
Returns
Task<int>
Returns a task that represents the asynchronous operation.
Remarks
ReselectRowAsync
is supported for SQL Select DataStore. Use ReselectRowAsync
to discard values the user has changed and replace them with values from the database after an update fails (due to a concurrent access error, for example).
Examples
The following code example modifies the values for the first row and then calls the ReselectRowAsync
asynchronous method to retrieve the original values for the first row from database again.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DWNet.Data;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class ReselectRowAsyncExample
{
private readonly SchoolContext _context;
public ReselectRowAsyncExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public async Task<int> Example1()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
datastore.Retrieve();
Console.WriteLine("Department ID: {0}; Department Name: {1}",
datastore.GetItem<int>(0, "departmentid"),
datastore.GetItem<string>(0, "name"));
// Modified the values for the first row.
datastore.SetItem(0, "departmentid", 7);
datastore.SetItem(0, "name", "Department Name");
Console.WriteLine("Department ID: {0}; Department Name: {1}",
datastore.GetItem<int>(0, "departmentid"),
datastore.GetItem<string>(0, "name"));
int result = 0;
try
{
// Calls ReselectRowAsync to retrieve values for the first row from database again.
// It will send SQL commands to database.
result = await datastore.ReselectRowAsync(0);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("Department ID: {0}; Department Name: {1}",
datastore.GetItem<int>(0, "departmentid"),
datastore.GetItem<string>(0, "name"));
return result;
/*This code produces the following output:
Department ID: 1; Department Name: Engineering
Department ID: 7; Department Name: Department Name
Department ID: 1; Department Name: Engineering
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x