none
querying the model not the database, what does it mean exactly? RRS feed

  • Question

  • I keep reading that Linq to entities is about querying the entity data model rather than the database but I dont quite understand what that means, since the Linq queries are to be translated to SQL queries that will be executed against the target data source such as SQL Server then the results will be materialized into objects of types defined in the model so how is that querying the model itself?
    Saturday, March 10, 2012 8:46 AM

Answers

  • Yes, they just meant that the code written by a developper will not *appear* to "act" against a database. The code will perform queries and other actions against an entity model and this is all what you'll see in the code.

    It doesn't mean that behind the scene, the model doesn't turn this into actual database queries, will materialize entities etc... It just means that those "details" are now hidden behind the entity model abstraction and won't be visible in your own code...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by Paulos Elias Monday, March 12, 2012 8:29 PM
    Saturday, March 10, 2012 9:32 PM

All replies

  • Hi,

    It doesn't refer to what actually happens behind the scene but just to the "abstraction level" you are using. It just means that the database is "hidden" behind the model and that what you actually see is that your code is querying an entity data model, not a database (and the underlying table, column names could be different or even someone could change the db and update the mapping, you would query the model the same way without even knowing the db has been changed).

    It's a bit like when running a SQL query you don't mind about the job that is done behind the scene (handling the database file, transmitting data across the network or whatever) you just think about it as sending a SQL query and getting a resultset as the goal of SQL was precisely to abstract away database file handling details.


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Proposed as answer by Kris444 Saturday, March 10, 2012 10:51 AM
    Saturday, March 10, 2012 9:58 AM
  • so what you mean is that that is what we would see but its actually querying the database instead?
    Saturday, March 10, 2012 8:08 PM
  • Yes, they just meant that the code written by a developper will not *appear* to "act" against a database. The code will perform queries and other actions against an entity model and this is all what you'll see in the code.

    It doesn't mean that behind the scene, the model doesn't turn this into actual database queries, will materialize entities etc... It just means that those "details" are now hidden behind the entity model abstraction and won't be visible in your own code...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    • Marked as answer by Paulos Elias Monday, March 12, 2012 8:29 PM
    Saturday, March 10, 2012 9:32 PM