我想加入 SqlKata 中的静态字符串值,但无法弄清楚如何做到这一点。
这就是我的查询需要的方式
LEFT JOIN [tblUserGroupMembers] AS [TUGM] ON ([TUGM].[UserGroupID] = [TUG].[UserGroupId] AND [TUGM].[UserType] = 'Primary')
LEFT JOIN [tblUsers] AS [TU] ON [TU].[UserId] = ISNULL([TIA].[UserId],[TUGM].[UserId])
如您所见,我想加入
TUGM.UserType
= Primary 和另一个加入[TU].[UserId] = ISNULL([TIA].[UserId],[TUGM].[UserId])
SqlKata 查询:
var dbQuery = db.Query("tblInvoices AS TI")
.Join("tblInvoiceActions AS TIA", "TIA.InvoiceID", "TI.InvoiceID")
.Join("APM_MASTER__INVOICE AS AMI", "AMI.InvoiceID", "TI.InvoiceID")
.LeftJoin("tblUserGroups AS TUG", "TUG.UserGroupId", "TI.UserGroupId")
.LeftJoin("tblUserGroupMembers AS TUGM",
j => j.On("TUGM.UserGroupID", "TUG.UserGroupId")
.On("TUGM.UserType","['Primary']"))
.LeftJoin("tblUsers AS TU", "TU.UserId", "[ISNULL(TIA.UserId,TUGM.UserId)]")
.LeftJoin("tblConnections AS TC", "TC.ConnectionID", "TI.ConnectionID");