我有桌子
eventid int -- not PK key but with autoincrement
jobid -- PK autoincrement disabled
userid int -- PK autoincrement disabled
Run Code Online (Sandbox Code Playgroud)
要更新jobID,我会执行以下操作:
var itemforupdate = context.table.where(n=>n.eventid == someparameter).FirstorDefault()
Run Code Online (Sandbox Code Playgroud)
我正确地从数据库中获取项目,但在分配时:
itemforupdate.jobID = 5;
context.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
之后context.SaveChanges()我得到的错误:
属性"jobID"是对象的关键信息的一部分,无法修改
如何从Entity Framework更新jobID来解决这个问题?
我在 SQL 中有一个连接,我需要在 linq 中编写它,这是select声明:
select * from products p
left join customer cust
on((cust.identifier = p.orgID or cust.identifier = p.personalno) and cust.identifier is not null);
Run Code Online (Sandbox Code Playgroud)
如何在 linq 中编写此语句?