Show / Hide Table of Contents

    IDataStoreBase.OnUpdateEnd(object sender, DwUpdateEventArgs e) Method

    .NET Standard 2.x

    This method is called after DataStore has finished updating the data. It triggers the UpdateEnd event by default, and it can be overridden in a child class of the DataStore.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public void OnUpdateEnd(object sender, DwUpdateEventArgs e);
    

    Parameters

    sender System.Object

    An event sender in which the event occurred. It is a reference to the current DataStore by default.

    e DWNet.Data.DwUpdateEventArgs

    A DwUpdateEventArgs object which can be used to pass by event arguments.

    Remarks

    In the UpdateEnd event, you can use:

    • DwUpdateEventArgs.RowsInserted to receive the number of rows inserted;

    • DwUpdateEventArgs.RowsUpdated to receive the number of rows updated;

    • DwUpdateEventArgs.RowsDeleted to receive the number of rows deleted.

    Examples

    The following code example demonstrates how to use the OnUpdateEnd method.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreBaseExamples
    {
        public class OnUpdateEndExample
        {
            private readonly SchoolContext _context;
    
            public OnUpdateEndExample(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);
    
                // Defines what to do when update is completed
                datastore.UpdateEnd +=
                   (sender, args) =>
                    {
                        // Executes the following code after update is executed.
                        Console.WriteLine("After Update, RowsUpdated count: {0}",
                            args.RowsUpdated);
                    };
    
                // Retrieves rows from the database for datastore.
                datastore.Retrieve();
    
                Console.WriteLine("After Retrieve, Rowcount: {0}",
                    datastore.RowCount);
    
                // Modifies the value for budget in row 1.
                datastore.SetItem(0, "budget", 220000.00m);
    
                // Deletes the last row.
                datastore.DeleteRow(datastore.RowCount - 1);
    
                // OnUpdateEnd method is called internally to invoke the 
                // UpdateEnd event.
                datastore.Update();
    
                /*This code produces the following output:
                
                After Retrieve, Rowcount: 4
                After Update, RowsUpdated count: 2           
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon