Created
November 23, 2013 20:01
-
-
Save okaram/7619208 to your computer and use it in GitHub Desktop.
Web API With Dapper
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
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