Show / Hide Table of Contents

    IDataStoreBase.OnUpdateStart(object sender, DwUpdateEventArgs e) Method

    .NET Standard 2.x

    This method is called when the DataStore is about to update the data. It triggers the UpdateStart 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 OnUpdateStart(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 UpdateStart event, you can set DwUpdateEventArgs.IsCancel to true to cancel the update.

    Examples

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

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreBaseExamples
    {
        public class OnUpdateStartExample
        {
            private readonly SchoolContext _context;
    
            public OnUpdateStartExample(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 about to begin.
                datastore.UpdateStart +=
                    (sender, args) =>
                    {
                        // Executes the following code before update is executed.
                        Console.WriteLine("Call UpdateStart, 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", 350000.00m);
    
                // Modifies the value for name in the last row.
                datastore.SetItem(datastore.RowCount - 1, "name", "New Department");
    
                // OnUpdateStart method is called internally to invoke the 
                // UpdateStart event.
                datastore.Update();
    
                /*This code produces the following output:
                
                After Retrieve, Rowcount: 4
                Call UpdateStart, RowsUpdated count: 0
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon