this is my stored procedure which i created. I added in my .edmx file by clicking "update database model".
How do i call the procedure in mvc3razor application using c#.
CREATE PROCEDURE GetGradeBook
AS
BEGIN
DECLARE @AssignmentList varchar(3000),@Sql varchar(max)
SET @AssignmentList =STUFF((SELECT DISTINCT ',[' + assignmentname + ']' FROM assignment where coursesectionid='b78a6efe-ac77-4e49-806a-fc2fad71068b' FOR XML PATH('')),1,1,'')
SET @Sql ='select *
from
(
select p.firstname,p.lastname,a.assignmentname,a.pointspossible
from person2 p
inner join coursesectionroster cs
on cs.personid = p.personid
inner join assignment a
on a.coursesectionid = cs.coursesectionid
left join assignmentsubmission asg
on a.assignmentid=asg.assignmentid
where cs.coursesectionid=''b78a6efe-ac77-4e49-806a-fc2fad71068b''
and cs.courserole=2
)t
PIVOT(SUM(pointspossible) FOR assignmentname IN(' + @AssignmentList + '))p'
EXEC (@SQL)
END
Loading
dilipkumar reganaPosted Sep 11, 2013, 1:44 AM
vidhyaPosted Jul 2, 2013, 5:00 AM
first we need to add function import . Then only we can map the function.
Riyaz AkhtarPosted Jul 2, 2013, 4:48 AM
http://msdn.microsoft.com/en-us/data/hh859577
Iftikar HussainPosted Jul 2, 2013, 4:48 AM
Regards,
Iftikar
vidhyaPosted Jul 2, 2013, 4:39 AM
Instead of showing the column names it shows "Selected stored procedure returns no columns".
Thats great problem for me now. First i need to rectify this.
Iftikar HussainPosted Jul 2, 2013, 4:23 AM
Please follow the below step
1. Right click on EDMX and click option Add->Function Import
2. Enter Function Import Name, Select the correct Stored Procedure from combo, Select Complex option as Returns a Collection of
3. Click on Get Column Information button. it will return your column information
4. Click on Create New Complex Type button
5. Enter the Complex type name and click OK button
6. Now it will create a new Complex result type under .tt
7.Then in your controler you can call this function
Regards,
Iftikar
vidhyaPosted Jul 2, 2013, 3:56 AM
I cant able to add directly. so i tried to function import. it also got failed.
vidhyaPosted Jul 2, 2013, 3:43 AM
In AddFunctionImport,
i need to select complex. No complex added there. i m trying to add the complex by clicking "GetColumnInformation" it returns "Selected stored procedure returns no columns".
How do i add the complex type.
Riyaz AkhtarPosted Jul 2, 2013, 3:34 AM
http://msdn.microsoft.com/en-us/data/jj557860
http://msdn.microsoft.com/en-us/data/jj593489
Sanjeeb LenkaPosted Jul 2, 2013, 3:30 AM
vidhyaPosted Jul 2, 2013, 3:25 AM
code in
<oracle.dataaccess.client><settings><addname="SCOTT.EMP_GETLIST.RefCursor.o_cursor"value="implicitRefCursor bindinfo='mode=Output'"/>settings>oracle.dataaccess.client>Kunal VaishyaPosted Jul 2, 2013, 3:24 AM
Sanjeeb LenkaPosted Jul 2, 2013, 3:16 AM
http://yassershaikh.com/how-to-call-stored-procedure-from-entity-framework-in-asp-net-mvc/
http://www.itorian.com/2012/09/using-stored-procedure-entity-framework.html
vidhyaPosted Jul 2, 2013, 3:15 AM
Iftikar HussainPosted Jul 2, 2013, 2:34 AM
Please refer the below link
http://social.msdn.microsoft.com/Forums/en-US/a7e15e64-5724-44ce-a047-d256424a1e7f/how-to-call-stored-procedure-from-entity-framework
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/using-stored-procedure-entity-framework-in-mvc-4-to-create/
Regards,
Iftikar