Translate string.Join and string.Concat
See original GitHub issuestring.Join
would be a cool feature to have now and then. Some database engines support this with an aggregate function, others such as SQL Server need a little hand-holding. Pluses include terser code and less data over the wire when projecting, since the alternative to concatenating on the server would be returning a child string collection for each row and concatenating the collection after the query. (If I understand correctly, child collections are usually transferred by joining each row of the child collection to the original row set and duplicating a lot of data.)
I expect that this would be low priority for you to add to EF, but I’m curious if anything is being done to allow extensions to the LINQ to query translation. We would be thrilled to implement string.Join
support ourselves if it didn’t require modifying EF and provider source code every release and recompiling.
I wasn’t able to find anything about extending LINQ to query translation so I apologize if I missed it, but I know you are dramatically refactoring for EF Core and I can imagine many cool scenarios would be possible if there was an extension point in LINQ querying.
Depends on:
Issue Analytics
- State:
- Created 8 years ago
- Reactions:29
- Comments:43 (15 by maintainers)
Top GitHub Comments
FWIW starting with SQL Server 2017,
STRING_AGG()
should be a good option for the translation ofstring.Join()
in the cases that the input comes from a table.Until now it just happens that we haven’t added enough features that are version specific for it to become really compelling but we could certainly add API to enable groups of features for a version of the database server, e.g. the most granular version:
A bit more general:
or even shorter:
We have discussed this before, e.g. at https://github.com/aspnet/EntityFramework/issues/9000#issuecomment-311867375 and https://github.com/aspnet/EntityFramework/pull/3011#r38792929.