Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Translate method in Entity framework not found

Translate method in Entity framework not found

Scheduled Pinned Locked Moved C#
databasehelpcsharpdotnetquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    meeram39
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • M meeram39

      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.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I'm pretty sure that you should be using Translate on an ObjectContext.

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        I'm pretty sure that you should be using Translate on an ObjectContext.

        M Offline
        M Offline
        meeram39
        wrote on last edited by
        #3

        Thanks a lot!!!. I was using DBContext. I was little aware of ObjectContext. I done some examples now. This link is useful, hope it will be useful for someone. This link also much useful how to get objectcontext references. Thanks again.. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups