专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > .NET新技术

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

发布时间:2011-06-26 19:41:15 文章来源:www.iduyao.cn 采编人员:星星草
跪求解决方法,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();
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: