Skip to content

Instantly share code, notes, and snippets.

@okaram
Created November 23, 2013 20:01
Show Gist options
  • Save okaram/7619208 to your computer and use it in GitHub Desktop.
Save okaram/7619208 to your computer and use it in GitHub Desktop.
Web API With Dapper
using Dapper;
namespace DapperCleanDemo.Controllers
{
public class PeopleController : ApiController
{
public IEnumerable<dynamic> GetResultById(string id)
{
using (var conn = new SqlConnection(@"Server=localhost\sqlexpress;Database=XmlTest;Trusted_Connection=True"))
{
var rows = conn.Query("select id,name FROM people WHERE Id=@Id", new { Id = id });
return rows;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment