Show / Hide Table of Contents

    ISqlBuilderLoader.LoadAsync(params object[] parameters) Method

    .NET Standard 2.x

    Asynchronously retrieves data by the built SQL statement.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public Task<ILoadable<TModel>> LoadAsync(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

    Task<ILoadable<TModel>>

    Returns a task that represents the asynchronous operation.

    Examples

    The following code example demonstrates how to use the LoadAsync 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 LoadAsyncExample
        {
            private readonly SchoolContext _context;
            private ISqlModelMapper mapper;
            
            public LoadAsyncExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
                mapper = _context.SqlModelMapper;
            }
    
            public async Task<int> Example1()
            {
                var builder = mapper.GetQueryBuilder<DepartmentByName>();
                
                int count = (await builder.LoadAsync("English")).ToList().Count;
                
                Console.WriteLine("Count: {0}", count);
                
                return count;
                
                /*The code produces the following output:
                 
                    Count: 1
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon