none
Difference between Native SQL and Entity SQL RRS feed

  • Question

  • Hi,
     
    I have gone through an article of using EntityConnection, EntityCommands for executing Entity sql queries. But I was unable to understand that Why are we using Entity sql? Why not directly using the Classes and objects for processing CRUD operations on database?
     
    Or If we want to execute sql queries then why we are using Entity Sql , why not directly Ado.net ?
     
    Is there any performance difference or something else?
    I have already gone through the page http://msdn.microsoft.com/en-us/library/bb738573.aspx[^]. But I want answer in a more simpler way. Can you please answer me?
     
    Thanks
    • Moved by Vicky SongMicrosoft employee Monday, August 20, 2012 9:17 AM (From:Visual Studio Database Development Tools (Formerly "Database Edition Forum"))
    Friday, August 17, 2012 6:41 AM

Answers

  • Hi,

    As far as I am aware Entity SQL is only really used be people who are dynamically building the Entity SQL string because they do not know what the query should be until runtime. It can be easier to do this with string manipulation with entity sql than the alternatives.

    EF can be used to execute standard SQL, but not to return data, and the commands executed will not update the context in any way so the update will not be tracked. Entity SQL would be required to retrieve data and materialize it into entities.

    I am not an expert on entity sql by any means, so it is possible that I have missed something here but as far as I understand it that is the way it is.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Monday, August 20, 2012 5:10 PM
    Moderator

All replies

  • Hi Jayant,

    I am moving your case to the ADO.NET Entity Framework and LINQ to Entities forum so that you can get better support there.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

    Monday, August 20, 2012 9:17 AM
  • Hi,

    As far as I am aware Entity SQL is only really used be people who are dynamically building the Entity SQL string because they do not know what the query should be until runtime. It can be easier to do this with string manipulation with entity sql than the alternatives.

    EF can be used to execute standard SQL, but not to return data, and the commands executed will not update the context in any way so the update will not be tracked. Entity SQL would be required to retrieve data and materialize it into entities.

    I am not an expert on entity sql by any means, so it is possible that I have missed something here but as far as I understand it that is the way it is.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Monday, August 20, 2012 5:10 PM
    Moderator