在 LINQ 查询中删除多条记录的最佳方法? [英] Best way to delete multiple records in a LINQ query?

查看:14
本文介绍了在 LINQ 查询中删除多条记录的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 LINQ 一次性删除多条记录的最佳方法是什么?

解决方案

用Linq2Sql删除记录

<前>CustomerDataContext ctx = new CustomerDataContext("连接字符串");var customer = ctx.Customers.Where(c => c.Name == "david");ctx.Customers.DeleteAllOnSubmit(customers);ctx.SubmitChanges();

What is the best way to remove multiple records in one go with LINQ?

解决方案

To delete records with Linq2Sql

CustomerDataContext ctx = new CustomerDataContext("connection string");
var customers = ctx.Customers.Where(c => c.Name == "david");

ctx.Customers.DeleteAllOnSubmit(customers);
ctx.SubmitChanges();

这篇关于在 LINQ 查询中删除多条记录的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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