Click here to Skip to main content
15,891,033 members

Execute Stored Procedure using Entity framework

Vi(ky asked:

Open original thread
I want to execute this Procedure using entity framework

SQL
/****** Object:  StoredProcedure [dbo].[ProjectTableRowCount]    Script Date: 12/27/2013 16:23:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[ProjectTableRowCount]
( 
	@ProjectId int,
	@SearchKey varchar(50) ,
	@PageNo int , 									
	@PazeSize int 
)
AS
BEGIN

SELECT  AllTableInfo.Id , AllTableInfo.tableName ,AllTableInfo.[rowCount] ,  AllTableInfo.isActive    FROM
( SELECT [Table].Id, TABLE_INFO.*, [Table].isActive,  ROW_NUMBER() OVER(ORDER BY [Table].isActive) AS rownumber FROM [Table]  
INNER JOIN  
(
SELECT      A.Name 'tableName', SUM(B.rows) AS 'rowCount'
FROM        sys.objects A
INNER JOIN  sys.partitions B ON A.object_id = B.object_id
WHERE       A.type = 'U' 
GROUP BY    A.schema_id, A.Name
) AS TABLE_INFO

ON  [Table].tableName = TABLE_INFO.tableName ) AS AllTableInfo
INNER JOIN ProjectTable	ON
ProjectTable.tablesId = AllTableInfo.Id
WHERE ProjectTable.ProjectId = @ProjectId 
AND AllTableInfo.tableName LIKE '%'+@SearchKey +'%'           
AND rownumber > (( @PageNo -1) * @PazeSize )
                         AND rownumber <= ((@PageNo - 1)* @PazeSize)+ @PazeSize

END


my Entity code

C#
public virtual ObjectResult<ProjectTableRowCount_Result> ProjectTableRowCount(Nullable<int> projectId, string searchKey, Nullable<int> pAGENO, Nullable<int> pazeSize)
        {
            var projectIdParameter = projectId.HasValue ?
                new ObjectParameter("projectId", projectId) :
                new ObjectParameter("projectId", typeof(int));
    
            var searchKeyParameter = searchKey != null ?
                new ObjectParameter("SearchKey", searchKey) :
                new ObjectParameter("SearchKey", typeof(string));
    
            var pAGENOParameter = pAGENO.HasValue ?
                new ObjectParameter("PAGENO", pAGENO) :
                new ObjectParameter("PAGENO", typeof(int));
    
            var pazeSizeParameter = pazeSize.HasValue ?
                new ObjectParameter("PazeSize", pazeSize) :
                new ObjectParameter("PazeSize", typeof(int));
    
            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<ProjectTableRowCount_Result>("ProjectTableRowCount", projectIdParameter, searchKeyParameter, pAGENOParameter, pazeSizeParameter);
        }



But the error is

"The function import could not be found in the container"


I add the function import by the information given on
http://msdn.microsoft.com/en-us/library/bb896231.aspx

Please help ...
Tags: C#, Entity Framework, SQL Server, MVC4

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900