如何使用Code第一种方法和MVC4中的viewmodel进行更新删除? [英] How to do update delete using Code first approach and viewmodel in MVC4?

查看:68
本文介绍了如何使用Code第一种方法和MVC4中的viewmodel进行更新删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我有一个视图,它包含22个字段。我的数据库完全正常化。我有13个表来保存这22个字段。我使用Code First方法和ViewModel进行插入。我做了同样的事情,如下面链接中提到的插入过程



http://www.codeproject.com/Tips/651495/InsertingIGN-into -Multiple-Tables-using-Code-Fir



现在插入工作正常现在我想在MVC4中使用codefirstapproach和ViewModel进行UPDATE,DELETE,INDEX过程我不知道这该怎么做 。对于Index我写内连接查询。但是对于更新和删除过程?我不知道如何从多个能够更新和删除过程中检索数据。请任何人给我一个例子的解决方案。



预先谢谢。

Hi i have one view and it contain 22 fields. My DB is fully normalized. I have 13 tables to save those 22 fields. I used Code First approach and ViewModel for insertion . I did same as like which is mentioned in the below link for insertion process

http://www.codeproject.com/Tips/651495/Inserting-Data-into-Multiple-Tables-using-Code-Fir

Now insertion is working fine now i want to do UPDATE, DELETE, INDEX process using codefirstapproach and ViewModel in MVC4 i donno how to do this . For Index i write Inner Join query . But for Update and Delete Process? i donno how to retreive data from multiple able for update and delete process. Please any one give me solution with one example.

Advance Thanks.

推荐答案

只需要你需要了解

1.如何创建上下文类和模型类

2.如何创建和与控制器和模型通信

3.如何创建视图/局部视图。

还需要了解

数据注释和/或流畅的API



你可以选择以下链接....



在ASP.NET MVC应用程序中使用实体框架实现基本的CRUD功能| ASP.NET站点 [ ^ ]

在MVC中使用Entity Framework 5.0 Code First方法进行CRUD操作 [ ^ ] br />


CRUD操作使用实体框架6 MVC 5中的Code First方法 [ ^ ]

C#Corner:错误显示 [ ^ ]



使用实体框架代码优先方法的CRUD操作 [ ^ ]





我希望借助上述链接,您可以实现目标。
Simply You need to understand
1. how to create context class and model class
2. How to create and communicate with controller and model
3. how to create view/ partial view.
also need to understand
Data annotation and/or fluent API

You can prefer following links....

Implementing Basic CRUD Functionality with the Entity Framework in ASP.NET MVC Application | The ASP.NET Site[^]
CRUD Operations Using Entity Framework 5.0 Code First Approach in MVC[^]

CRUD operation with Entity Framework 6 Code First approach in MVC 5[^]
C# Corner : Error Display[^]

CRUD Operations Using Entity Framework Code-First Approach[^]


I hope with the help of above link you can we meet your goal.


这篇关于如何使用Code第一种方法和MVC4中的viewmodel进行更新删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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