使用EF

时间:2016-10-04 10:57:52

标签: c# sql sql-server entity-framework tsql

我需要将一个字符串列表传递给我的存储过程Sp_Calculate_TimeSheet_Global_Info所以我创建了这两种类型:

CREATE TYPE [dbo].[Type_cmd] AS TABLE (
[TypeName] [varchar](50) NULL
)
GO
CREATE TYPE [dbo].[Etape_cmd] AS TABLE (
[EtapeName] [varchar](50) NULL
)
GO   

存储过程的签名如下:

DECLARE @return_value int

EXEC    @return_value = [dbo].[Sp_Calculate_TimeSheet_Global_Info]
        @DateDebut = NULL,
        @DateFin = NULL,
        @UserId = NULL,
        @CA = NULL,
        @Client = NULL,
        @EtapeName = NULL,
        @TypeName = NULL

SELECT  'Return Value' = @return_value

GO

问题在于,当我首先使用EF数据库时,我试图在模型中获得此过程

public virtual int Sp_Calculate_TimeSheet_Global_Info(Nullable<System.DateTime> dateDebut, Nullable<System.DateTime> dateFin, Nullable<int> userId, string cA, string client)
        {
            var dateDebutParameter = dateDebut.HasValue ?
                new ObjectParameter("DateDebut", dateDebut) :
                new ObjectParameter("DateDebut", typeof(System.DateTime));

            var dateFinParameter = dateFin.HasValue ?
                new ObjectParameter("DateFin", dateFin) :
                new ObjectParameter("DateFin", typeof(System.DateTime));

            var userIdParameter = userId.HasValue ?
                new ObjectParameter("UserId", userId) :
                new ObjectParameter("UserId", typeof(int));

            var cAParameter = cA != null ?
                new ObjectParameter("CA", cA) :
                new ObjectParameter("CA", typeof(string));

            var clientParameter = client != null ?
                new ObjectParameter("Client", client) :
                new ObjectParameter("Client", typeof(string));

            return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction("Sp_Calculate_TimeSheet_Global_Info", dateDebutParameter, dateFinParameter, userIdParameter, cAParameter, clientParameter);
        }

用户定义的表格无法识别!!!

所以我需要知道如何解决这个问题?

0 个答案:

没有答案