Show / Hide Table of Contents

    IDataStore<TModel>.GetForUpdate(int index) Method

    .NET Standard 2.x

    Obtains the TModel object according to the specified row index number.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    TModel GetForUpdate(int index);
    

    Parameters

    index System.Int32

    The zero-based index number of the row.

    Returns

    TModel

    Returns the TModel object which contains the data for the row found.

    Remarks

    This method makes a shallow copy of the data, therefore, any changes made to this TModel will affect the data source. To make a deep copy of the data, refer to GetModel.

    The index number starts from 0, which is consistent with C#.

    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 GetForUpdateExample
        {
            private readonly SchoolContext _context;
    
            public GetForUpdateExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore<D_Department>(_context);
    
                datastore.Retrieve();
    
                var department = datastore.GetForUpdate(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

    Back to top Generated by Appeon