Dilshad Ashraf

Dilshad Ashraf

  • NA
  • 84
  • 4.3k

Getting value -1 when we are calling stored procdre with EF

Jul 23 2019 2:44 PM
Hi All,
I am using first time Entity Framework with stored procedure for getting records based on parameters.
I am getting -1(minus one) value. I'm not getting the records.
Why value -1 is coming and why records are not coming.
Below are the code:
public JsonResult BidCategory(tblCategory objTblCategory)
{
db = new ProductDBEntities();
var companyid = new SqlParameter("@companyid", objTblCategory.CompanyId);
var siteid = new SqlParameter("@siteid", objTblCategory.SiteId);
var isdeleted = new SqlParameter("@isdeleted", objTblCategory.IsDeleted);
var ispublished = new SqlParameter("@ispublished", objTblCategory.IsPublished);
var data = db.Database.ExecuteSqlCommand("uspGetCategory @CompanyId,@SiteId,@IsDeleted,@IsPublished", companyid, siteid, isdeleted, ispublished);//Getting -1
return Json(data, JsonRequestBehavior.AllowGet);
}
Below are the stored procedure:
CREATE PROC uspGetCategory
(
@CompanyId INT,
@SiteId INT,
@IsDeleted BIT,
@IsPublished BIT
)
AS
BEGIN
SELECT CategoryId,
CategoryName
FROM tblCategory WITH(NOLOCK)
WHERE CompanyId = @CompanyId
AND SiteId = @SiteId
AND IsDeleted = @IsDeleted
AND IsPublished = @IsPublished
AND ParentCategoryId IS NULL
END
 
Please give me solution for above code.
Find the attachments screens and code
Thanks & Regards
Dilshad Ashraf

Attachment: getting_-1.rar

Answers (2)