Show / Hide Table of Contents

    SqlRawBuilder.SqlRawBuilder(string name = "") Constructor

    .NET Standard 2.x

    Initializes a new instance of the SqlRawBuilder class.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      public SqlRawBuilder(string name = "");
    

    Parameters

    name System.String

    (Optional) The name for this SqlRawBuilder object.

    Examples

    The following code example demonstrates how to create a SqlRawBuilder object.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.SqlRawBuilderExamples
    {
        public class SqlRawBuilderExample
        {
            private readonly SchoolContext _context;
    
            public SqlRawBuilderExample(SchoolContext dataContext)
            {
                // Sets data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Creates a SqlRawBuilder object.
                ISqlRawBuilder query = new SqlRawBuilder();
    
                // Uses this object to build a SQL statement.
                query.Raw("select * from course where courseid = @id",
                           SqlBuilder.Parameter<int>("id"));
    
                // Outputs the generated SQL statement.
                string sql = query.ToSqlString(_context);
                Console.WriteLine(sql);
    
                /*This code produces the following output:
                
                SELECT
                 *
                FROM [course]
                WHERE [courseid] = @id
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon