This code is failing with the error: "Must declare the scalar value @prodID". Any suggestions?
using (var ctx = new StewieDataModel())
{
string productID = "81";
var techData = ctx.Database.SqlQuery<TechData>("dbo.usp_DS_GetTechData @prodID", productID).ToList();
}
Here's the model:
namespace DatasheetData
{
using System;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
public partial class StewieDataModel : DbContext
{
public StewieDataModel()
: base("name=StewieConnectionString")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
}
}
}
Here's the class I want to populate:
namespace DatasheetData
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("usp_DS_GetTechData")]
public partial class TechData
{
public string TestCategory { get; set; }
public string TestName { get; set; }
public string TestResultLabel { get; set; }
public string TestResult { get; set; }
public string TestMethod { get; set; }
}
}
Here's how I call it successfully in SSMS:
DECLARE @return_value int
EXEC @return_value = [dbo].[usp_DS_GetTechData]
@prodID = "81"
SELECT 'Return Value' = @return_value
GO