Search
 
SCRIPT & CODE EXAMPLE
 

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;
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: convert number of days into months c# 
Csharp :: split lines c# 
Csharp :: get both item and index in c# 
Csharp :: how to send button name for method in c# 
Csharp :: entity framework core genetare class using existing database 
Csharp :: how to pass id from view to controller in asp.net core 
Csharp :: authentication and authorization in asp.net c# with example 
Csharp :: unity2d movement 
Csharp :: json serialization 
Csharp :: how to add to a list in c# 
Csharp :: array declaration in c# 
Csharp :: c# loop array 
Csharp :: How to add rigidbody as a variable 
Csharp :: rotate along normal unity 
Csharp :: unity lerp 
Csharp :: Unity rainbow color changing object 
Csharp :: sum of digit of number c# 
Csharp :: string.QueryString c# 
Csharp :: unity soft body 
Csharp :: exceeds your upload_max_filesize ini directive (limit is 2048 KiB). 
Csharp :: how to change all values in dictionary c# 
Csharp :: Printing pattern in c# 
Csharp :: how to get the today date in c# 
Csharp :: C# System.nanoTime 
Csharp :: aspx receive variable from url 
Csharp :: moving camera with touch screen unity 
Csharp :: how to hide the title bar of window in monogame 
Csharp :: spin with rigidbody 2d unity 
Csharp :: c# remove xml invalid characters 
Csharp :: c# check port in remote pc 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =