开发者

Entity framework and database logic

i have a question that's being around for several years. As all you know entity framework is an ORM tool that tries to model the database to an object oriented access model. All the samples I've seen are quering directly to the database tables. So, which is the role of the views in the database now?. The views were used to model the database in a more friendly way, that is, several physical tables, one logic table. This was great for example in hidding the complex relational model on stored procedure开发者_开发百科s as queryng the views inside them was much easier than reproducing the query joins over and over on each stored procedure. So the question is, why is entity framework so good if stored procedures can not take benefit of it?.

i will try to explain the same in another way. You have a table called category. You have another table called elements. Each element can be in several categories and one category can contain several elements. For each category i want to calculate how many elements has (this is a simple but imagine that this calculating has a very complex formula). And now comes the problem:

Choice 1: Create a view VCategory with this calculation. Choice 2: Include the table category in entity framework and then extending the class to include the calculation.

Pros choice 1: The calculation is avaliable to everyone. Contras choice 1: The view is not updatable.

Pros choice 2: The table is updatable Contras choice 2: The calculation is only avaliable to .NET compliant systems.

dubts on choice one 1: how to handle this update with entity framework?. Importing the view and mapping the insert, updates, delete with stored procedures?.

dubts on choice one 2: The stored procedue can not benefit from entity framework. What to do if one stored procedure on database needs this calculation?.


Don't really understand what you mean...

Actually you can prolly use your orm with views if they are updatable... so what about using orm + procedures? You can still use your db views with your entity framework and you'll get a model in a "more friendly way".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜