ISqlBuilder.Clone() Method
.NET Standard 2.x |  Current Version (1.0.1) 
Makes a copy of the current ISqlBuilder object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
  ISqlBuilder Clone();
Returns
A copy of the current ISqlBuilder object.
Examples
The following code example demonstrates how to use the Clone method.
using System;
using SnapObjects.Data;
namespace Appeon.ApiDoc.ISqlBuilderExamples
{
    public class CloneExample
    {
        private readonly SchoolContext _context;
        public CloneExample(SchoolContext dataContext)
        {
            // Sets the data context
            _context = dataContext;
        }
        public void Example()
        {
            // Builds a SQL statement.
            var sqlBuilder = new SqlQueryBuilder();
            sqlBuilder.Select("name")
                    .From("Department");
            // Makes a copy.
            var sqlBuilderClone = (SqlQueryBuilder)sqlBuilder.Clone();
            // Adds the Where clause.
            sqlBuilderClone.WhereValue("DepartmentId", 1);
            string sql = sqlBuilder.ToSqlString(_context);
            Console.WriteLine("The SQL SELECT statement (sqlBuilder): \n{0}", 
                sql);
            sql = sqlBuilderClone.ToSqlString(_context);
            Console.WriteLine();
            Console.WriteLine("The SQL SELECT statement (sqlBuilderClone): \n{0}", 
                sql);
            /*This code produces the following output:
            
            The SQL SELECT statement:
            SELECT
             [name]
            FROM [Department]
            WHERE ([DepartmentId] = 1)         
            */
            /* This code produces the following output:
            The SQL SELECT statement (sqlBuilder):
            SELECT
             [name]
            FROM [Department]
            The SQL SELECT statement (sqlBuilderClone):
            SELECT
             [name]
            FROM [Department]
            WHERE ([DepartmentId] = 1)
            */
        }
    }
}
Applies to
.NET Standard
2.x