Show / Hide Table of Contents

    ISqlQueryBuilder.Select(string column) Method

    .NET Standard 2.x

    Adds a column to the select list of a SELECT clause.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      ISqlQueryBuilder Select(string column);
    

    Parameters

    column System.String

    The column name 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 column) method to select a column for the SELECT statement; the Select method can only choose one column at a time.

    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 Example3()
            {
    
                // Declares SqlQueryBuilder.
                var sqlbuilder = new SqlQueryBuilder();
    
                // Retrieves the Name and Budget values from Department table
                sqlbuilder.Select("name")
                    .Select("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