1

I am using ASP.NET MVC 4.5 and EF. I import the stored procedures into my ADO.NET Entity Data Model. I have my .edmx and XX.tt with my StoredProcedure_Result.cs.

I use

var result = dbcontext.SP(Param).AsEnumerable().First();

My problem is that those stored procedures that have

select count(id) as Count from table

doesn't appear in my SP_Result.cs

Any ideas?

3
  • I would open the .edmx file and "Update Model from Database" and make sure that the stored procedure in question is selected to add or refresh. Commented Jul 23, 2015 at 14:24
  • I did that. My Stored Procedure appears on my .edmx, but it does not appear on my _Result.cs... Furthermore, if I change it, and put "select id from table" instead of "select count(id) from table".. it appears on my _results.cs. It seems it does not like "count()" syntax.. Commented Jul 23, 2015 at 14:33
  • Did you try calling stored procedure anyway? A "_Result.cs" class might not be created in these cases because it would just be a int. EF might not bother creating a dedicated type just to represent an int. That is my best guess. Commented Jul 23, 2015 at 14:39

1 Answer 1

1

I just tried this out myself and did not see a "_Result.cs" class created either for the sproc that just returns count(). I'm guessing that a _Result.cs class does not need to be created because it is just a single int, and a specific type is not needed. I was still able to call the sproc though. You could obtain the int like this...

var result = db.getCount().First(); 
int i = (int)result; 
Sign up to request clarification or add additional context in comments.

2 Comments

OK, but in that case, when i call "var result = dbcontext.SP(Param).AsEnumerable().First();" where do i get the result count() from the SP.?
This works fine for me... var result = db.getCount().First(); int i = (int)result;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.