No mapping exists from object type System.RuntimeType to a known managed provider native type

Viewed 13191

I have a stored procedure with the signature

PROCEDURE [dbo].[spValidateID]
    @ScanCode       VARCHAR(50),
    @Name           VARCHAR(50) = NULL OUTPUT,
    @ScanTime       DATETIME = NULL OUTPUT,
    @ValidationCode INT = 0 OUTPUT

This is supposed to return a validationCode and also populate the name and scanTime variables. I need to give it scanCode value while calling.

in my C# code I am doing like this.

using (var context = new DBEntities())
{
    var pScanCode = new SqlParameter("ScanCode", scanCode);
    var opName = new SqlParameter("Name", name);
    var opScanTime = new SqlParameter("ScanTime", scanTime);
    var opValidationCode = new SqlParameter("ValidationCode", validationCode);

    var test = context.ExecuteStoreQuery<int>("spValidateID @ScanCode, @Name, @ScanTime, @ValidationCode", pScanCode, opName, opScanTime, opValidationCode);
}

but while running this I m getting error No mapping exists from object type System.RuntimeType to a known managed provider native type.

any idea??

1 Answers
Related