Search Results for

    Show / Hide Table of Contents
    View Source

    Class SqlTemplate

    Represents a template for generating SQL queries in the persistence layer.

    Inheritance
    object
    Namespace: Umbraco.Cms.Infrastructure.Persistence
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    public class SqlTemplate

    Methods

    View Source

    Arg(string)

    Gets a named argument.

    Declaration
    public static object Arg(string name)
    Parameters
    Type Name Description
    string name
    Returns
    Type Description
    object
    View Source

    ArgIn<T>(string)

    Returns an enumerable representing the argument for a SQL WHERE IN clause.

    Declaration
    public static IEnumerable<T?> ArgIn<T>(string name)
    Parameters
    Type Name Description
    string name

    The name of the argument to be used in the SQL template.

    Returns
    Type Description
    IEnumerable<T>

    An System.Collections.Generic.IEnumerable<T> containing a single default value of type T. This is used to ensure compatibility with NPoco when no values are provided.

    Type Parameters
    Name Description
    T

    The type of the elements in the argument list.

    View Source

    Arg<T>(string)

    Retrieves the value of a named argument used in a WHERE expression.

    Declaration
    public static T? Arg<T>(string name)
    Parameters
    Type Name Description
    string name

    The name of the argument to retrieve.

    Returns
    Type Description
    T

    The argument value of type T if found; otherwise, null.

    Type Parameters
    Name Description
    T

    The expected type of the argument value.

    View Source

    Sql()

    Returns a new NPoco.Sql<> instance initialized with the current SQL context and SQL string.

    Declaration
    public Sql<ISqlContext> Sql()
    Returns
    Type Description
    Sql<ISqlContext>

    A new NPoco.Sql<> instance.

    View Source

    Sql(params object[])

    Creates a new SQL query from the template, using the specified arguments.

    Declaration
    public Sql<ISqlContext> Sql(params object[] args)
    Parameters
    Type Name Description
    object[] args

    Arguments to be formatted into the SQL template.

    Returns
    Type Description
    Sql<ISqlContext>

    A new NPoco.Sql<> instance representing the formatted SQL query.

    Remarks

    must pass the args, all of them, in the proper order, faster

    View Source

    SqlNamed(object)

    Creates a SQL query using named arguments provided via an object's properties.

    Declaration
    public Sql<ISqlContext> SqlNamed(object nargs)
    Parameters
    Type Name Description
    object nargs

    An object whose public properties are used as named arguments for the SQL query template.

    Returns
    Type Description
    Sql<ISqlContext>

    A NPoco.Sql<> instance representing the constructed SQL query.

    Remarks

    can pass named args, not necessary all of them, slower so, not much different from what Where(...) does (ie reflection) Throws System.InvalidOperationException if required arguments are missing or if unknown arguments are provided. This method uses reflection to match property names to template argument names.

    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX