ADO.Entity模型问题 [英] ADO.Entity Model Question

查看:70
本文介绍了ADO.Entity模型问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
实体框架4.0参考表未显示?如何使用实体框架模型从这些表中删除记录.

感谢和问候

Mohit Sharma

Hi All,
Entity Framework 4.0 reference tables not showing? How to delete the records from these tables using Entity FrameWork Model.

Thanks And Regards

Mohit Sharma

推荐答案

,假设实体==实体
该模型与他的使用"相关联
并且您要删除
的记录 ID = 1的记录"表
您可以使用


assuming that the entity == Entities
the model is linked with his "using"
and you want to delete a record of the
"Record" table with id = 1
you can use


using (Entities entitiesContext = new Entities())
    {
        var e = from x in entitiesContext.Records
                where x.Id = 1
                select x;
        Record record = e.FirstOrDefault();
        entitiesContext.Records.DeleteObject(record);
        entitiesContext.SaveChanges();
    }






如果记录不仅是一个记录而且很多,那么必须使用带有DeleteObject方法的foreach循环

在循环之外,您可以保存更改






if the record is not only one but a lot, you have to use a foreach loop with the DeleteObject method

and outside of the loop you can save changes


这篇关于ADO.Entity模型问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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