为什么这个简单的LINQ to SQL更新查询不起作用?

时间:2011-07-09 12:29:46

标签: c# .net wpf linq linq-to-sql

我正在使用VS 2010,MS SQL Server 2008,WPF 4

PalQuotationDataContext _palQuotationDataContext = new PalQuotationDataContext(); 
public void UpdateItemInformation(EItemInformation anItemInformation)
{
     var itemInformation = _palQuotationDataContext.ITEMs.Single(item =>
                                      item.IM_ID == anItemInformation.Id);
     itemInformation.IM_NAME = anItemInformation.Name;
     itemInformation.IM_DESCRIPTION = anItemInformation.Description;
     itemInformation.IM_BRAND = anItemInformation.Brand;
     itemInformation.IM_ORIGIN = anItemInformation.Origin;
     itemInformation.IM_ACESS_BY = anItemInformation.AccessBy;

     _palQuotationDataContext.SubmitChanges();
}

1 个答案:

答案 0 :(得分:2)

您的表格需要primary key

相关问题