Show / Hide Table of Contents

    ISqlUpdateBuilder.SetRaw(string setRaw) Method

    .NET Standard 2.x

    Specifies one or more columns whose data will be changed by a raw SQL.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

      ISqlUpdateBuilder SetRaw(string setRaw);
    

    Parameters

    setRaw System.String

    A string of raw SQL which specifies one or more columns whose data will be changed.

    Returns

    SnapObjects.Data.ISqlUpdateBuilder

    Returns the current ISqlUpdateBuilder object.

    Examples

    The following code example demonstrates how to use the SetRaw(string setRaw) method.It uses a raw SQL string to modify the Name value to "Chinese" for the record where DepartmentID=1 in the "Department" table.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.ISqlUpdateBuilderExamples
    {
        public class SetRawExample
        {
            private SchoolContext _context;
    
            public SetRawExample(SchoolContext dataContext)
            {
                // Sets Data Context.
                _context = dataContext;
            }
    
            public void Example()
            {
    
                // Declares SqlQueryBuilder.           
                var sqlbuilder = new SqlUpdateBuilder();
    
                // Modifies the Name value to "Chinese" for the record where DepartmentID=1 in the "Department" table
                sqlbuilder.Update("Department")
                       .SetRaw("Name='Chinese'")
                       .Where("DepartmentID", "1");
    
                // 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:
                UPDATE [Department] SET [Name]='Chinese'
                WHERE ([DepartmentID] = 1)
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon