Show / Hide Table of Contents

    SqlBuilder.Select(string[] columns) Method

    .NET Standard 2.x

    Creates an ISqlQueryBuilder object for building a SQL SELECT statement, and adds multiple columns to the select list of the SELECT clause.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

     public static ISqlQueryBuilder Select(string[] columns);
    

    Parameters

    columns System.String[]

    An array of column names to be added to the select list of the SELECT clause.

    Returns

    SnapObjects.Data.ISqlQueryBuilder

    Returns a newly created ISqlQueryBuilder object which can be used to build the SQL SELECT statement.

    Examples

    The following code example demonstrates how to use the Select(string[] columns) method to retrieve values in multiple columns from the "Department" table.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.SqlBuilderExamples
    {
        public class SelectExample
        {
            private SchoolContext _context;
    
            public SelectExample(SchoolContext dataContext)
            {
                // Sets Data Context.
                _context = dataContext;
            }
    
            public void Example2()
            {
    
                // Creates a SQL statement to retrieve the name and budget values from the "Department" table.
                var query = SqlBuilder
                    .Select(new string[] { "name", "budget" })
                    .From("Department");
    
                // Converts to raw SQL for the database corresponding to the data context.
                string sql = query.ToSqlString(_context);
    
                Console.WriteLine(sql);
                
                /*This code example produces the following output:           
    
                SELECT
                [name],
                [budget]
                FROM [Department]
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon