我使用EF的DBContext来执行存储过程。这是函数
public IEnumerable<Customer> GetCustomerInfoforSearch(string bfcSalesRecipientId, string companyName, string contactName, string phoneNumber, string emailId, string ageroProviderNumber)
{
var bfcSalesRecipientIdParam = new SqlParameter("@saleRecipientId", bfcSalesRecipientId);
var companyNameParam = new SqlParameter("@companyName", companyName);
var contactNameParam = new SqlParameter("@contactName", contactName);
var phoneNumberParam = new SqlParameter("@phoneNumber", phoneNumber);
var emailIdParam = new SqlParameter("@emailId", emailId);
var ageroProviderNumParam = new SqlParameter("@ageroProviderNumber", ageroProviderNumber);
object[] sqlParams = new object[] { bfcSalesRecipientIdParam, companyNameParam, contactNameParam, phoneNumberParam, emailIdParam, ageroProviderNumParam };
var result = Context.Database.SqlQuery<Customer>("dbo.Customer_SearchContact {0}, {1}, {2}, {3}, {4}, {5}", bfcSalesRecipientIdParam, companyNameParam, contactNameParam, phoneNumberParam, emailIdParam, ageroProviderNumParam).ToList();
return result;
}
但是这会引发以下错误:
SqlParameter已包含在另一个SqlParameterCollection
中