Show / Hide Table of Contents

    ISqlFromBuilder.From(string table) Method

    .NET Standard 2.x

    Adds a table or view (with no alias specified) to the FROM clause of the current object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      ISqlFromBuilder From(string table);
    

    Parameters

    table System.String

    The name of the table or view.

    Returns

    SnapObjects.Data.ISqlFromBuilder

    Returns the current ISqlFromBuilder object.

    Examples

    The following code example demonstrates how to use the From(string table) method to retrieve all the records from the "Department" table.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlFromBuilderExamples
    {
        public class FromExample
        {
            private SchoolContext _context;
    
            public FromExample(SchoolContext dataContext)
            {
                // Sets the Data Context
                _context = dataContext;
            }
    
            public void Example2()
            {
    
                // Declares SqlQueryBuilder.
                var sqlbuilder = new SqlQueryBuilder();
    
                // Builds a SQL statement to retrieve all the records from the "Department" table.
                sqlbuilder.Select("*")
                    .From("Department");
    
                // 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
                 *
                FROM [Department]         
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon