I have been having some issue with adding some string concatenation in my LINQ JOIN condition and its translation in Oracle sql query. This used to work fine on our legacy solution that was using EF. Let's take the following example:
var query = (from sub in connection.InvoiceSubStatuses
join lab in connection.Litteral
on "STN_ASP_PIE_STATUT_EXTERNE[" + sub.StatusCode + "]" + "{" + vendorId + "}" equals lab.Code
where sub.IsFlaggedDelete == 0
select new InvoiceSubStatusDTO
{
Description = lab.Libelle,
StatusCode = sub.StatusCode,
Id = sub.Id,
Culture = lab.Culture,
StatusType = sub.StatusType
});
This is interpreted as the following sql code:
SELECT "l".LIBELLE "Description", "s".CODE_STATUSFAC "StatusCode", "s".SYS_ID "Id", "l".CULTURE "Culture", "s".TYPE_STATUSFAC "StatusType"
FROM STATUSFAC "s"
INNER JOIN LITTERAUX "l" ON N'STN_ASP_PIE_STATUT_EXTERNE[' || COALESCE("s".CODE_STATUSFAC, N'') || N']' || N'{' || TO_NCHAR(:p__vendorId_0) || N'}' = "l".CODE
WHERE ("s".DIGITAL_LETTER = 1) AND ("s".SYS_FLAG_DEL = 0)
This causes an error , as Oracle doesn't allow 'N' text literal inside COALESCE ( COALESCE("s".CODE_STATUSFAC, N'')). If I manually change it to COALESCE("s".CODE_STATUSFAC, ''), the query works fine, but I don't know how to resolve this from Linq.
Has anyone encountered this issue and found a workaround?Thanks