Sql server 实体框架是否将SQL存储过程的默认返回值从0更改为-1?
尝试解决返回值问题时,EF4似乎没有按预期处理存储过程中的返回值 当我仅从SQLServerManagementStudio运行存储过程时,返回值为零。这是意料之中的。但是,当我从服务运行代码时,相同的存储过程调用返回-1Sql server 实体框架是否将SQL存储过程的默认返回值从0更改为-1?,sql-server,entity-framework,stored-procedures,Sql Server,Entity Framework,Stored Procedures,尝试解决返回值问题时,EF4似乎没有按预期处理存储过程中的返回值 当我仅从SQLServerManagementStudio运行存储过程时,返回值为零。这是意料之中的。但是,当我从服务运行代码时,相同的存储过程调用返回-1 using (var ctx = new LAMSEntities()) { ObjectParameter tempComputerId = new ObjectParameter("computerId", Guid
using (var ctx = new LAMSEntities())
{
ObjectParameter tempComputerId = new ObjectParameter("computerId", Guid.Empty);
ObjectParameter tempCustomerId = new ObjectParameter("customerId", string.Empty);
result = ctx.RegisterCustomerComputer_i(regCode, machineHashId, tempComputerId, tempCustomerId);
if (result != 0) //0 = success in SQL Stored Procedures
///TODO: may want to add logging at this point to determine what the cause of failure was.
return null;
CustomerRegistration cr = new CustomerRegistration();
cr.ComputerHash = machineHashId;
cr.ComputerId = Guid.Parse(tempComputerId.Value.ToString());
cr.CustomerId = tempCustomerId.Value.ToString();
cr.RegistrationCode = regCode;
cr.RegistrationDate = DateTime.Now;
return cr;
}
这是我服务电话中的代码。RegisterCustomerComputer_i是存储过程。如有任何建议或见解,我们将不胜感激。请尝试
ctx.RegisterCustomerComputer_i(regCode, machineHashId, tempComputerId, tempCustomerId).First();