CREATE PROCEDURE mysp_GetCustomers AS SELECT * FROM [dbo].CustomerNow our stored procedure is ready so I just need to change my CustomDB file from the my previous post example like following.
using System.Collections.Generic; namespace CodeSimplified.Models { public class CustomerDB { public IEnumerable<Customer> GetCustomers() { var databaseContext = new PetaPoco.Database("MyConnectionString"); return databaseContext.Query<Customer>("exec mysp_GetCustomers"); } } }
That's It. Now It's time to run this in browser and Here is the output.
In future post I will explain How we can use PetaPoco with parameterised stored procedure. Hope you liked it.. Stay tuned for more.. Happy programming.
No comments:
Post a Comment