我需要查询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
。