Show / Hide Table of Contents

    DataStore<TModel>.DataStore(DataContext dataContext, IEnumerable<TModel> items) Constructor

    .NET Standard 2.x

    Initializes a new instance of the DataStore class using a DataContext object and a sequence of TModel objects.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public DataStore(DataContext dataContext, IEnumerable<TModel> items);
    

    Parameters

    context SnapObjects.Data.DataContext

    A DataContext object which represents the entry to the database.

    items System.Collections.Generic.IEnumerable<TModel>

    A sequence of TModel objects which contain data.

    Examples

    The following code example creates a DataStore object and specifies data DataContext and inserts data to it.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    using System.Collections.Generic;
    
    namespace Appeon.ApiDoc.DataStore_GenericExamples
    {
        public class DataStore_GenericExample
        {
            private readonly SchoolContext _context;
    
            public DataStore_GenericExample(SchoolContext dataContext)
            {
                // Set Data Context
                _context = dataContext;
            }
    
            public void Example4()
            {
                var items = new List<D_Department>
                {
                    new D_Department{ Departmentid = 1, Name = "Design" },
                    new D_Department{ Departmentid = 2, Name = "Product" }
                };
    
                // Instantiates the datastore with d_department DataWind
                var department = new DataStore<D_Department>(_context, items);
    
                int row = department.RowCount;
                Console.WriteLine("Row Count = {0}", row);
    
                /*This code produces the following output:
                
                Row 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