In my previous post I have mentioned the path which we are going to follow for Entity Framework. This is the first post in the path. In this post I try to explain you guys how the Entity Framework works behind the scene.
Since we know that it is an ORM tool, so that implies that it some how provides extra features to your business entities so that they become more intelligent to know about the relations with other entities in the mode, the relationship, mapping with the database etc. That part is done by the Enity Data Model.
EDM contains your conceptual schema (CSDL), Store schema (SSDL) and mapping between Conceptual and Store schema i.e. MSL. We will dive inside the EDM in next post, for current post you treat EDM as a layer between Entity Framework and your database.
Once you have the model, then next thing you will ask that how our model gets aware of the data changes, dealing with the database etc. Well that part is done by Linq-to-Entities.
The Entity Framework uses information in the model and mapping files (which were defined in EDM) to translate object queries against entity types represented in the conceptual model into data source-specific queries. Query results are materialized into objects that the Entity Framework manages.
Over here first Entity Framework translates the developer’s query in to Lemda expression, and after that it pass the query to the data providers. Data providers returns result back to the Entity Framework, once the result is arrived, Entity Framework uses the Object Service to get the data and construct the objects or update existing depends upon the type of the query.
The Entity Framework provides the following ways to query a conceptual model and return objects:
- LINQ to Entities . Provides Language-Integrated Query (LINQ) support for querying entity types that are defined in a conceptual model.
- Entity SQL . A storage-independent dialect of SQL that works directly with entities in the conceptual model and that supports Entity Data Model concepts. Entity SQL is used both with object queries and queries that are executed by using the EntityClient provider. It is a SQL-like language that enables you to query conceptual models in the Entity Framework.
- Query builder methods. These methods enable you to construct Entity SQL queries using LINQ-style query methods. Basically these are the methods which expects object query, for example WHERE, DISTINCT, GroupBy, OrderBy are different kind of builder methods.
The Entity Framework includes the EntityClient data provider. This provider manages connections, translates entity queries into data source-specific queries, and returns a data reader that the Entity Framework uses to materialize entity data into objects. When object materialization is not required, the EntityClient provider can also be used like a standard ADO.NET data provider by enabling applications to execute Entity SQL queries and consume the returned read-only data reader.
The following diagram illustrates the Entity Framework architecture for accessing data:
The Entity Data Model Tools can generate a class derived from ObjectContext (the base class used for querying and working with entity data as objects.) that represents the entity container in the conceptual model. This object context provides the facilities for tracking changes and managing identities, concurrency, and relationships. This class also exposes a SaveChanges method that writes inserts, updates, and deletes to the data source. Like queries, these changes are either made by commands automatically generated by the system or by stored procedures that are specified by the developer.
Data Providers
The EntityClient provider extends the ADO.NET provider model by accessing data in terms of conceptual entities and relationships. It executes queries that use Entity SQL . Entity SQL provides the underlying query language that enables EntityClient to communicate with the database.
Cool, there is actually some good points on this blog some of my subscribers will find this relevant, I must send them a link, thank you.
ReplyDeleteHey! I know this is kinda off topic but I was wondering which blog platform are you using for this website? I'm getting sick and tired of Wordpress because I've had problems with hackers and I'm looking at options for another platform. I would be great if you could point me in the direction of a good platform.
ReplyDeleteHello, I found your blog in a new directory of blogs. I dont know how your blog came up. Your blog looks good. Have a nice day.
ReplyDeleteGreetings from Idaho! I'm bored to tears at work so I decided to browse your website on my iphone during lunch break. I really like the knowledge you present here and can't wait to take a look when I get home. I'm shocked at how fast your blog loaded on my cell phone .. I'm not even using WIFI, just 3G .. Anyways, wonderful site!
ReplyDeleteIt's a pity you don't have a donate button! I'd certainly donate to this outstanding blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to brand new updates and will talk about this blog with my Facebook group. Chat soon!
ReplyDeletehey guys thanks alot for all the insight. really liked the section. and iam going to give it a shot. if you have some other nice books or web sites on the content, love to hear from you. thanks over again.
ReplyDeleteOne of the best ways that I have found to stay motivated is by using a training journal. This way you can track your progress week for week, and ensure you make the necessary changes to each workout.
ReplyDeleteHello there! This post couldn't be written any better! Reading through this post reminds me of my old room mate! He always kept chatting about this. I will forward this write-up to him. Pretty sure he will have a good read. Thank you for sharing!
ReplyDeleteIt never ceases to amaze me how, with a bit of extra searching online, you can stumble on some of the most unique articles. I've added you to my bookmarks, I also have a pal, that will really enjoy this article, so ill send him, a link to your site, as well.
ReplyDelete