Show / Hide Table of Contents

    ISqlBuilderLoader.Load(params object[] parameters) Method

    .NET Standard 2.x

    Retrieves data by the built SQL statement.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public ILoadable<TModel> Load(params object[] parameters);
    

    Parameters

    parameters System.Object[]

    (Optional) One or more values that you want to use as retrieval arguments in the SQL SELECT statement.

    Returns

    SnapObjects.Data.ILoadable<TModel>

    Returns an ILoadable<TModel> object whose methods can be used to further obtain the result set, or perform data operations such as embedded queries.

    Examples

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

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading;
    using System.Threading.Tasks;
    using Appeon.ApiDoc.Models.School;
    using SnapObjects.Data;
    
    namespace Appeon.ApiDoc.ISqlBuilderLoaderExamples
    {
        public class LoadExample
        {
            private readonly SchoolContext _context;
            private ISqlModelMapper mapper;
            
            public LoadExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
                mapper = _context.SqlModelMapper;
            }
    
            public void Example()
            {
                var builder = mapper.GetQueryBuilder<DepartmentByName>();
                
                int count = builder.Load("English").ToList().Count;
                
                Console.WriteLine("Count: {0}", count);
                
                /*The code produces the following output:
                 
                    Count: 1
                */
            }
        }
    }
    

    Example Refer To

    Model Class: Department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon