日期:2014-05-17  浏览次数:20892 次

一个关于LINQ TO SQL的问题,DATACONTEXT类没有ADD方法?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Text;
using System.IO;




namespace Simple_Linq_to_SQL
{
public class tester
    {        
        static void Main()
        {

            AddCustomer();
            UpdateCustomer();
            Console.ReadKey();
        }
        private static void AddCustomer()
        {
            Console.WriteLine("Adding a new customer...");
            AdventureWorksAddressDataContext dc = new AdventureWorksAddressDataContext();
            dc.Log = Console.Out;
            Customer douglas = new Customer();
            douglas.FirstName = "douglas";
            douglas.LastName = "adams";
            douglas.EmailAddress = "douglas0@adventureworks.com";
            douglas.PasswordHash = "fake";
            douglas.PasswordSalt = "fake";
            douglas.ModifiedDate = DateTime.Today;
            douglas.rowguid = Guid.NewGuid();

            Address addr = new Address();
            addr.AddressLine1 = "lc sharp way";
            addr.City = "seattle";
            addr.PostalCode = "98011";
            addr.StateProvince = "washington";
            addr.CountryRegion = "united states";
            addr.ModifiedDate = DateTime.Today;
            addr.rowguid = Guid.NewGuid();
            CustomerAddress ca = new CustomerAddress();
            ca.AddressType = "main office";
            ca.Address = addr;
            ca.Customer =&n