简体   繁体   中英

Why this simple LINQ to SQL update query is not working?

I'm using 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();
}

Your table needs a primary key .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM