Show / Hide Table of Contents

    ISqlQueryBuilder.Select(string[] columns) Method

    .NET Standard 2.x

    Adds multiple columns to the select list of a SELECT clause.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      ISqlQueryBuilder Select(string[] columns);
    

    Parameters

    columns System.String[]

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

    Returns

    SnapObjects.Data.ISqlQueryBuilder

    Returns the current ISqlQueryBuilder object.

    Examples

    The following code example demonstrates how to use the Select(string[] columns) method to select multiple column for the SELECT statement; multiple columns can be placed in a string array.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlQueryBuilderExamples
    {
        public class SelectExample
        {
            private SchoolContext _context;
    
            public SelectExample(SchoolContext dataContext)
            {
                // Sets Data Context.
                _context = dataContext;
            }
    
            public void Example4()
            {
    
                // Declares SqlQueryBuilder.
                var sqlbuilder = new SqlQueryBuilder();
    
                // Retrieves the Name and Budget values from Department table
                sqlbuilder.Select(new string[] { "name", "budget" })
                    .From("Department", "dept");
    
                // Converts to raw SQL for the database corresponding to the data context.
                string sql = sqlbuilder.ToSqlString(_context);
    
                Console.WriteLine(sql);
                
                /*This code produces the following output:
                
                SELECT
                [name],
                [budget]
                FROM [Department] AS [dept]
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon