日期:2014-05-20  浏览次数:20722 次

跪求解决方法,linq to entity,entity sql

公司正用linq to entity实现项目开发,我现在接手的任务是将一个表中的数据选择性的插入另一个表中,
无论是linq to entity、linq to sql还是entity sql好像都不支持 DML 语句(insert、update、delete);
我该怎么办啊,那位大哥有好办法啊,把我愁坏了。解决不了就只能一个字段一个字段的赋值了,那样我会疯掉的
表中字段太多了。。。。

------解决方案--------------------
C# code

Northwnd db = new Northwnd(@"c:\Northwnd.mdf");

// Query for a specific customer.
var cust =
    (from c in db.Customers
     where c.CustomerID == "ALFKI"
     select c).First();

// Change the name of the contact.
cust.ContactName = "New Contact";

// Create and add a new Order to the Orders collection.
Order ord = new Order { OrderDate = DateTime.Now };
cust.Orders.Add(ord);

// Delete an existing Order.
Order ord0 = cust.Orders[0];

// Removing it from the table also removes it from the Customer’s list.
db.Orders.DeleteOnSubmit(ord0);

// Ask the DataContext to save all the changes.
db.SubmitChanges();