【发布时间】:2017-04-07 06:18:10
【问题描述】:
我想根据包含联接的查询的结果对表中的特定字段进行更新。将 OrmLite 与 ServiceStack 结合使用。
我的班级如下:
public class Document
{
public int Id { get; set; }
public string BCL_Code { get; set; }
public bool IsActive { get; set; }
public int DocumentTypeId { get; set; }
}
public class DocumentType
{
public int Id { get; set; }
public string TypeName { get; set; }
}
尝试使用以下代码对加入进行更新:
var q = db.From<Document>()
.Join<Document, DocumentType>(
(doc, type) => doc.DocumentTypeId == type.Id)
.Where(d => d.BCL_Code == "FR49")
.And<DocumentType>(t => t.TypeName == "Enrollment Process");
db.UpdateOnly(new Document { IsActive = false }, onlyFields: q);
我知道我可以更新特定字段,并且我知道如何进行联接,但是当我尝试在查询中包含联接,然后执行 UpdateOnly 时,我在 db.UpdateOnly 行上收到一条错误消息:
无法绑定多部分标识符“DocumentType.TypeName”。
是否可以对加入查询进行更新? 如果是这样,正确的做法是什么?
【问题讨论】: