Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

dapper sql builder where

    using (IDbConnection connection = new SqlConnection(ConnectionString))
    {
        var builder = new SqlBuilder();
        builder.Select("Id");
        builder.Select("FirstName");
        builder.Select("LastName");
        DynamicParameters parameters = new DynamicParameters();
        parameters.Add("@MyParam", id, DbType.Int32, ParameterDirection.Input);
        builder.Where("Id = @MyParam", parameters);
        var builderTemplate = builder.AddTemplate("Select /**select**/ from Authors /**where**/ ");
        var author = connection.Query<Author>(builderTemplate.RawSql, builderTemplate.Parameters).FirstOrDefault();
        return author;
    }
Source by riptutorial.com #
 
PREVIOUS NEXT
Tagged: #dapper #sql #builder
ADD COMMENT
Topic
Name
9+4 =