Show / Hide Table of Contents

    IDataStore.AsQueryable<TModel>() Method

    .NET Standard 2.x

    Converts the data in the specified buffer to an IQueryable.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    public IQueryable<TModel> AsQueryable<TModel>();
    

    Type Parameters

    TModel

    The type of a model class that matches with the current DataObject.

    Returns

    System.Linq.IQueryable<TModel>

    An IQueryable object.

    Examples

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

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    using System.Linq;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class AsQueryableExample
        {
            private readonly SchoolContext _context;
    
            public AsQueryableExample(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();
                Console.WriteLine("DataStore Primary Rowcount: {0}",
                   datastore.RowCount);
    
                // Converts to the IQueryable object.
                var departments = datastore.AsQueryable<D_Department>();
    
                Console.WriteLine("Converted Primary Rowcount: {0}",
                  departments.Count());
    
                // You can use some Linq methods.
                var department = departments.Where(x => x.Departmentid == 1);
                Console.WriteLine("Linq Rowcount: {0}",
                    department.Count());
    
                /*This code produces the following output:
                
                DataStore Primary Rowcount: 4
                Converted Primary Rowcount: 4     
                Linq Rowcount: 1
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon