I have a stored procedure that simply returns the total number of records divided by any value that is passed. This will help with pagination on the website.
However, I use an entity structure to bind to this stored procedure, and it returns -1for all calls. When I interrogate a stored procedure using SQL Management Studio, it returns with the correct value.
My stored procedure is as follows:
CREATE PROCEDURE [dbo].[GetAuditRecordPageCount]
@Count INTEGER
AS
RETURN ((SELECT COUNT(Id) FROM AuditRecords) / @Count) + 1
And my call to entity structure in C # is as follows:
int pageCount;
using (Entities entities = new Entities())
{
pageCount = entities.GetAuditRecordPageCount(count);
}
Did I write C # code correctly this way?
As requested in the SQL comments generated by EF:
exec [dbo].[GetAuditRecordPageCount] @Count=100