Show / Hide Table of Contents

    IDataStore.GetEnumerator() Method

    .NET Standard 2.x

    Obtains the enumerator that can be used to iterate through the DataStore.

    Inherited from IEnumerator<T>.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public IEnumerator GetEnumerator();
    

    Returns

    System.Collections.IEnumerator

    Returns an IEnumerator object that can be used to iterate through the DataStore.

    Examples

    The following code example demonstrates how to use the GetEnumerator method to obtain the enumerator that can be used to iterate through the DataStore.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class GetEnumeratorExample
        {
            private readonly SchoolContext _context;
    
            public GetEnumeratorExample(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);
    
                D_Department department;
    
                datastore.Retrieve();
    
    			//Obtains the enumerator that can be used to iterate through the DataStore.
                var departments = datastore.GetEnumerator();
    
                while (departments.MoveNext())
                {
                    department = (D_Department)departments.Current;
    
                    Console.WriteLine(
                        "Department ID: {0}; Department Name: {1}",
                        department.Departmentid,
                        department.Name);
                }
    
                /*This code produces the following output:
                 
                Department ID: 1; Department Name: Engineering
                Department ID: 2; Department Name: English
                Department ID: 4; Department Name: Economics
                Department ID: 7; Department Name: Mathematics
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon