Show / Hide Table of Contents

    IDataStore<TModel>.Clear() Method

    .NET Standard 2.x

    Clears data from all buffers.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public void Clear();
    

    Examples

    The following code example shows how to use the Clear method to clear data from all buffers.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class ClearExample
        {
            private readonly SchoolContext _context;
    
            public ClearExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Instantiates a DataStore object with datawindow object: d_department.
                var datastore = new DataStore<D_Department>(_context);
    
                datastore.Retrieve();
    			
    			// Removes the first row from the DataStore.
                datastore.RemoveAt(0);
    			
    			// Sets the Name column in the first row to Engineering New.
                datastore.SetItem(0, "Name", "Engineering New");
    			
    			// Filters rows by the filter criterion (Name = Engineering New).
                datastore.Filter(a => a.Name.Equals("Engineering New"));
    
                // Clears data from all buffers
                datastore.Clear();
    
                Console.WriteLine("TotalCount: {0}", datastore.TotalCount);
                Console.WriteLine("DeletedCount: {0}", datastore.DeletedCount);
                Console.WriteLine("FilteredCount: {0}", datastore.FilteredCount);
                Console.WriteLine("ModifiedCount: {0}", datastore.ModifiedCount);
    
                /*This code produces the following output:
                
                TotalCount: 0
                DeletedCount: 0
                FilteredCount: 0
                ModifiedCount: 0
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon