Show / Hide Table of Contents

    ISqlBuilderCache.Get(string sqlBuilderName) Method

    .NET Standard 2.x

    Gets an ISqlReadOnlyBuilder object by the specified name.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    ISqlReadOnlyBuilder Get(string sqlBuilderName);
    

    Parameters

    sqlBuilderName System.String

    The name for the ISqlBuilder object when it is cached.

    Returns

    SnapObjects.Data.ISqlReadOnlyBuilder

    Returns an ISqlReadOnlyBuilder object by the specified name.

    Examples

    The following code example demonstrates how to get an ISqlReadOnlyBuilder object via the cache name.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlBuilderCacheExamples
    {
        public class GetExample
        {
            private readonly SchoolContext _context;
    
            public GetExample(SchoolContext context)
            {
                _context = context;
            }
    
            public void Example()
            {
                // Creates a SqlQueryBuilder object.
                var build = SqlBuilderFactory.Create<ISqlQueryBuilder>("original sql");
                build.Select("select Title from Course wherer CourseID = 1050");
    
                // Generates a SqlBuilderCache object via SqlBuilderFactory.Cache.
                var cache = SqlBuilderFactory.Cache;
    
                // Injects the SqlQueryBuilder to the SqlBuilderCache object.
                cache.Set("querySql", build, true);
    
                // Gets the ISqlReadOnlyBuilder object whose name is "querySql".
                var get = cache.Get("querySql");
    
                Console.WriteLine("SqlBuild Name = {0}", get.Name);
    
                /*This code produces the following output:
                
                SqlBuild Name = original sql
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    See Also

    Set(String, ISqlBuilder, Boolean)

    GetModifiable<TSqlBuilder>(String)

    Back to top Generated by Appeon