我需要一个 Linq to Entities 查询,结果是一个用“,”分隔的 unic 字符串。我尝试Cont = String.Join(", ", op.OperacionesContenedores.Select(Function(jj) jj.Id.ToString).ToArray())
例子:
(From op In dContext.Operaciones
Join opTr In dContext.OperacionesTransito On opTr.idOperacion Equals op.id
Group Join opTrContenedor In dContext.OperacionesContenedores On opTr.idOperacion Equals opTrContenedor.IdOperacion Into grpOpTrContenedor = Group
From opTrContenedor In grpOpTrContenedor.DefaultIfEmpty()
Select New With {.idOperacion = op.id,
.Expediente = op.ReferenciaEmpresaResponsable,
.ReferenciaCliente = op.ReferenciaEmpresaCliente,
.Cont = String.Join(", ", op.OperacionesContenedores.Select(Function(jj) jj.Id.ToString).ToArray())
}).Distinct().AsQueryable
这应该返回“Expediente”、“referenciaCliente”、“con1、cont2、cont3”,但在查询执行中会产生错误:
LINQ to Entities does not recognize the method 'System.String Join(System.String, System.String[])' method, and this method cannot be translated into a store expression
.