Show / Hide Table of Contents

    SqlUpdateBuilder.SqlUpdateBuilder(string name = "") Constructor

    .NET Standard 2.x

    Initializes a new instance of the SqlUpdateBuilder class.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      public SqlUpdateBuilder(string name = "");
    

    Parameters

    name System.String

    (Optional) The name for this SqlUpdateBuilder object.

    Examples

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

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.SqlUpdateBuilderExamples
    {
        public class SqlUpdateBuilderExample
        {
            private SchoolContext _context;
    
            public SqlUpdateBuilderExample(SchoolContext dataContext)
            {
                // Sets Data Context.
                _context = dataContext;
            }
    
            public void Example()
            {
                /// Creates a SqlUpdateBuilder object.
                ISqlUpdateBuilder update = new SqlUpdateBuilder();
    
                // Uses this object to update the "Department" table where DepartmentID=1, 
                // by dynamically modifying the Name value.
                update.Update("Department")
                       .Set("Name", SqlBuilder.Parameter<string>())
                       .Where("DepartmentID", "1");
    
                // Outputs the generated SQL statement.
                string sql = update.ToSqlString(_context);
                Console.WriteLine(sql);            
    
                /*This code produces the following output:
                
                UPDATE [Department] SET [Name] = @p0
                WHERE ([DepartmentID] = 1)
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon