Translate method in Entity framework not found
-
I have a stored procedure that returns multiple result set. I tried to use Translate method to handle this, however, I am not able to call this method, as it is giving error such a method doesn't exist. I am using .Net Framework 4.5 and Entity Framework 5.0. Following is what I have tried.
using (var db = new MyEntities())
{
using (IDbConnection oaConnection = db.Database.Connection)
{
// 3. Create a new instance of the OACommand class.
using (IDbCommand oaCommand = oaConnection.CreateCommand())
{
// 4. Set the CommandType property.
oaCommand.CommandType = CommandType.StoredProcedure;// 5. Set the CommandText property. oaCommand.CommandText = "gsp\_get\_emp\_details"; oaCommand.Parameters.Add(empInput.EmployeeId); oaCommand.Parameters.Add(empInput.UserId); oaCommand.Parameters.Add(empInput.RoleList); // 6. Execute the command and materialize the car entities using (IDataReader dataReader = oaCommand.ExecuteReader()) { EmployeeData empData = db.Translate(dataReader as DbDataReader);
}
}
}
}I tried using by calling
using System.Data.Objects;
, however it is giving compile error on db.Translate. It is giving the message that "project does not contain a definition for Translate...". May I know what's wrong with the above code? Thanks in advance for any help.
-
I have a stored procedure that returns multiple result set. I tried to use Translate method to handle this, however, I am not able to call this method, as it is giving error such a method doesn't exist. I am using .Net Framework 4.5 and Entity Framework 5.0. Following is what I have tried.
using (var db = new MyEntities())
{
using (IDbConnection oaConnection = db.Database.Connection)
{
// 3. Create a new instance of the OACommand class.
using (IDbCommand oaCommand = oaConnection.CreateCommand())
{
// 4. Set the CommandType property.
oaCommand.CommandType = CommandType.StoredProcedure;// 5. Set the CommandText property. oaCommand.CommandText = "gsp\_get\_emp\_details"; oaCommand.Parameters.Add(empInput.EmployeeId); oaCommand.Parameters.Add(empInput.UserId); oaCommand.Parameters.Add(empInput.RoleList); // 6. Execute the command and materialize the car entities using (IDataReader dataReader = oaCommand.ExecuteReader()) { EmployeeData empData = db.Translate(dataReader as DbDataReader);
}
}
}
}I tried using by calling
using System.Data.Objects;
, however it is giving compile error on db.Translate. It is giving the message that "project does not contain a definition for Translate...". May I know what's wrong with the above code? Thanks in advance for any help.
I'm pretty sure that you should be using
Translate
on anObjectContext
. -
I'm pretty sure that you should be using
Translate
on anObjectContext
.