Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. Create Procedure [dbo].[usp_RolesList]
  2. (@WhereCond varchar(50))
  3. AS
  4. Begin
  5. Set NoCount ON
  6. Declare @SQLQuery AS Varchar(max)
  7. Set @SQLQuery = 'Select * From dbo.AspNetRoles ' + @WhereCond
  8. Execute sp_Executesql @SQLQuery
  9.  
  10. End
  11. and this is my c# code that I am using for executing the results
  12. var idParam = new SqlParameter
  13. {
  14. ParameterName = "WhereCond",
  15. Value = "where Id > 0"
  16. };
  17. var courseList = ctx.Database.SqlQuery<UserRoles>("exec usp_RolesList @WhereCond ", idParam).ToList<UserRoles>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement