如何使用实体框架4.0从两个不同的表实体创建模型 [英] How to create model from two different table entity usin entity framework 4.0

查看:84
本文介绍了如何使用实体框架4.0从两个不同的表实体创建模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有四个表Employee_Details,Employee_Contact_Details,Department_Wise_Employee和Skill_Wise_Employee。



我必须从四个不同的表实体制作一个模型。

所以我必须只编写一个CRUD操作,因为所有的fours表都会更新。

I have four tables Employee_Details,Employee_Contact_Details,Department_Wise_Employee and Skill_Wise_Employee.

I have to make one model from four different table entities.
So i have to write only one CRUD operation due to which all fours table get updated.

推荐答案

你可以创建所有4个表的视图从您的4个表Employee_Details,Employee_Contact_Details,Department_Wise_Employee和Skill_Wise_Employee中选择了字段。现在根据View中的属性创建View的实体模型。对于View,请参考以下网站。



http://odetocode.com/articles/299.aspx [ ^ ]



http://www.w3reso urce.com/sql/creating-views/create-view-with-join.php [ ^ ]



您可以编写LINQ查询,同时考虑您的实体模型对应于创建的View的类。确保数据库中的View名称应该与您的模型实体类名相同。然后您可以像在普通实体模型中一样执行CRUD操作。
You can create a 'View' of all the 4 tables which will have selected fields from your 4 tables Employee_Details,Employee_Contact_Details,Department_Wise_Employee and Skill_Wise_Employee.Now create an entity model of your 'View' according to your attributes present in 'View'.For 'View' refer to following sites.

http://odetocode.com/articles/299.aspx[^]

http://www.w3resource.com/sql/creating-views/create-view-with-join.php[^]

You can write LINQ queries taking into account your entity model class corresponding to created View.Make sure that the View name in database should be same with your model entity class name.Then you can carry out CRUD operations as like as in normal entity models.


Quote:

你必须保持所有四个表之间的关系。

然后你必须添加一个ADO.NET您项目中的实体框架。

从您的数据库中选择所有必需的表格。



最后一个是使用LINQ to SQL查询用于编写CURD查询的

You have to maintain relationship between all the four table's.
Then you have to add a ADO.NET Entity Framework in your project.
select all the required table's from your database.

And the last one is to use LINQ to SQL query for writing CURD query's


这篇关于如何使用实体框架4.0从两个不同的表实体创建模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆