数据库中的多对多首先接近mvc crud操作 [英] Many to Many in database first approach mvc crud operation

查看:67
本文介绍了数据库中的多对多首先接近mvc crud操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在EF数据库第一种方法中使用多对多关系。我在sql中有以下表结构



How to use many to many relationship in EF database first approach. I am having following table structure in sql

Table 1:- studentMaster 
Table 2:- Subjects





我的Model1。 edmx和sql表结构图片在这里



图片



我知道如何使用实体框架使用DAtabase First方法执行CRUD操作但是如何在表格时执行crud操作有很多很多关系。我之前也在codeproject上提出了我的问题但没有给出适当的帮助



My Model1.edmx and sql table structure pic is here

Pic

I know how to perform CRUD operation using Entity Framework using DAtabase First approach but how to perform crud operation when table have many to many relationship . I have also put my question on codeproject previously but no proper help is given

推荐答案

确定,假设你的意思是asp.net mvc,我们必须区分服务器端和客户方。服务器端,实体框架负责这一点,请参阅 http://stackoverflow.com/ questions / 19342908 / entity-framework-many-to-many-mapping [ ^ ]

客户端 - 顺便说一句,我不是asp程序员 - 这看起来更像是一个与wcf相关的问题(使用休息为粗暴行动服务)。而且,是的,它可能有点棘手,因为例如json rest服务需要坚持某个模式才能实现这一点,而且,使用的orm / odm必须要注意该模式以相应地组装/重组json数据,并需要实现一些查询和路由逻辑(依赖于执行最终连接的位置,和/或查询如何通过层传递)。在最好的情况下,原子查询在数据库上本地执行,并且只有请求的字段以分页方式返回给客户端。也许jaydata框架可以帮助你。我认为它能够消耗各种服务(其中包括wcf相关的东西)。因此,如果纯wcf中没有构建解决方案,那么使用jaydata客户端的odata服务可能是您最好的选择,请参阅 http://jaydata.org [ ^ ]



ok, assuming that you mean asp.net mvc, we have to differencate between server side and client side. server side, the entity framework takes care of that, see http://stackoverflow.com/questions/19342908/entity-framework-many-to-many-mapping[^]
client side - by the way, I am no asp programmer - this seems more like a wcf related question (using a rest service for crud operations). And, yes, it may be a bit tricky, because e.g. a json rest service needs to stick to a certain schema to accomplish that, and, further more the orm/ odm used must be aware to that schema to assemble/ reassemble the json data accordingly and needs to implement some query and routing logic (depening on where the final joins are executed, and/or how the query is passed through the layer). in the best case an atomic query is natively executed on the database and only the requested fields are returned to the client in a paginated manner. maybe the jaydata framework can help you. I think it is able to consume a variety of services (among these are wcf related stuff). so if there is no build in solution in pure wcf, consuming an odata service thith jaydata client side may be your best bet, see http://jaydata.org[^]

Quote:

在CRUD应用程序中,您必须处理复杂的数据类型,并且一对一,一对多甚至多对许多协会。没有适当的框架和没有数据库编程经验,当你想要创造梦想的应用时,这可能是一项艰苦的工作和痛苦。







使用JayData,问题的复杂性显着降低。您可以使用JaySvcUtil实用程序获取实体上下文定义,该实用程序在OData元数据和JavaScript上下文定义之间进行转换。您可以在此过程后立即开始工作。

In CRUD applications, you have to deal with complex data types and one-to-one, one-to-many and even many-to-many associations. Without a proper framework and no database programming experience, this can be a hard work and a pain while you want to create the application of your dreams.



With JayData the complexity of the problems are reducing significantly. You can grab the entity context definition with JaySvcUtil utility, which translates between OData metadata and JavaScript context definition. You can start work immediately after this procedure.


这篇关于数据库中的多对多首先接近mvc crud操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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