Show / Hide Table of Contents

    IDataStoreBase.ReselectRow(int row) Method

    .NET Standard 2.x

    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 int ReselectRow(int row);
    

    Parameters

    row System.Int32

    A zero-based index number of the row.

    Returns

    System.Int32

    Returns 1 if it succeeds and -1 if the row cannot be reselected (for example, the DataStore cannot be updated or the row was deleted by another user).

    Remarks

    ReselectRow is supported for SQL Select DataStore. Use ReselectRow 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 ReselectRow method to retrieve the original values for the first row from database again.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreBaseExamples
    {
        public class ReselectRowExample
        {
            private readonly SchoolContext _context;
    
            public ReselectRowExample(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();
    
                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", 10);
                datastore.SetItem(0, "name", "Department Name");
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(0, "departmentid"),
                                   datastore.GetItem<string>(0, "name"));
    
                // Calls ReselectRow to retrieve values for the first row from database again.
                // It will send SQL commands to database.
                datastore.ReselectRow(0);
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(0, "departmentid"),
                                   datastore.GetItem<string>(0, "name"));
    
                /*This code produces the following output:
                 
                Department ID: 1; Department Name: Engineering
                Department ID: 10; 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

    Back to top Generated by Appeon