首页 新闻 会员 周边

LINQ to Entity 中怎么给外键赋值进行修改

0
悬赏园豆:5 [已关闭问题]

assetsEntities ass = new assetsEntities();
public ActionResult LowValueConsumablesUpdate(tbLowValueConsumables low,string Fid)
{
        tbLowValueConsumables item = ass.tbLowValueConsumables.Include("tbAssetType").FirstOrDefault(p => p.LVid == low.LVid);
           item.Amount = low.Amount;
           item.TotalPrice = low.TotalPrice
           item.tbAssetType.Fid =Fid;;//在这里报错:属性“Fid”是对象的键信息的一部分,不能修改。
           ass.SaveChanges();
           return View();
}

雨戈的主页 雨戈 | 初学一级 | 园豆:190
提问于:2009-12-07 14:06
< >
分享
其他回答(1)
0

要不就先delete再插入新记录?

Ryan.Sun | 园豆:360 (菜鸟二级) | 2009-12-08 01:08
0

根据Fid查找出tbAssetType的实体后再赋值

item.tbAssetType = object  //你查出来的那个对象。

云孤天 | 园豆:189 (初学一级) | 2009-12-22 13:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册