利用LINQ to SQL进行数据的检索、更新与删除操作
在数据处理中,LINQ to SQL是一个强大的工具,它允许我们使用面向对象的方式与数据库进行交互。下面将详细介绍如何使用LINQ to SQL进行数据的检索、更新和删除操作。
1. 数据检索
要使用生成的LINQ to SQL代码从映射的三个表中检索数据,可将 Program.cs 的内容替换为以下代码:
using System;
using System.Linq;
using System.Text;
namespace AdventureWorksDBML
{
// Main program
public class Tester
{
static void Main( )
{
AdventureWorksAddressDataContext dc = new
AdventureWorksAddressDataContext( );
// Uncomment the statement below to show the
// SQL statement generated by LINQ to SQL.
// dc.Log = Console.Out;
// Find one customer record.
Customer donna = dc.Customers.Single(c =&g
超级会员免费看
订阅专栏 解锁全文
861

被折叠的 条评论
为什么被折叠?



