Last active
June 2, 2024 12:25
-
-
Save ChrisMoney/247105266da0ab6db896a477e16a4706 to your computer and use it in GitHub Desktop.
Dapper Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Connection and transaction passed in from factory | |
IEnumerable object GetData(connection, transaction) { | |
string sql = "SELECT * FROM Person WHERE FirstName = @FirstName And LastName = @LastName | |
And Company = @Company And Title = @Tile And Email = @Email"; | |
var parameter = new DynamicParameters(); | |
parameter.Add("@Id",con.Id,dbType: DbType.Int32,direction:ParameterDirection.InputOutput); | |
parameter.Add("@FirstName", con.FirstName); | |
parameter.Add("@LastName", con.LastName); | |
parameter.Add("@Company", con.Company); | |
parameter.Add("@Title", con.Title); | |
parameter.Add("@Email", con.Email); | |
var products = connection.Query<Product>(sql).ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment