Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在数据上下文中显示表/类的列表,选择几个并将它们从数据上下文中删除。我知道如何获取表列表,但是如何以编程方式从数据上下文中删除/删除它们?
我不确定如何选择要删除的多个项目,但是如果您使用 LINQ 并通过查询选择它们,则可以使用以下代码:
var items = DataContext.Items.Where(item => item.ItemId == selectedId); foreach(var item in items) DataContext.Items.DeleteObject(item);