Entity framework core 如果复合键中的一个字段可为空,如何使Linq Join工作?
LicenceTypeId是一个可为空的字段-这就是为什么如果使用复合键,则无法编译以下代码-仅对简单键可以: 如果我使用这样的东西-Entity framework core 如果复合键中的一个字段可为空,如何使Linq Join工作?,entity-framework-core,left-join,linq-to-entities,Entity Framework Core,Left Join,Linq To Entities,LicenceTypeId是一个可为空的字段-这就是为什么如果使用复合键,则无法编译以下代码-仅对简单键可以: 如果我使用这样的东西-x1=license.licenseTypeId??:0-它被转换为在SQL中合并,这是我希望避免的。我需要一个由3个字段直接左连接 var licences = from licence in DbSet join licenceType in DbContext.LicenceTypes
x1=license.licenseTypeId??:0
-它被转换为在SQL中合并,这是我希望避免的。我需要一个由3个字段直接左连接
var licences =
from licence in DbSet
join licenceType in DbContext.LicenceTypes
on new { x1 = licence.LicenceTypeId, x2 = currentLanguageCode, x3 = CentralToolsFieldTypes.LICENCE }
equals new { x1 = licenceType.NumberValue, x2 = licenceType.LanguageCode, x3 = licenceType.CodeName } into licenceTypes
from licenceType in licenceTypes.DefaultIfEmpty()
select new { licence, licenceType };