question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Translate string.Join and string.Concat

See original GitHub issue

string.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:closed
  • Created 8 years ago
  • Reactions:29
  • Comments:43 (15 by maintainers)

github_iconTop GitHub Comments

14reactions
divegacommented, Jul 11, 2017

FWIW starting with SQL Server 2017, STRING_AGG() should be a good option for the translation of string.Join() in the cases that the input comes from a table.

5reactions
divegacommented, Jul 11, 2017

since there is just one general EFCore-package for SQLServer one would break the compatibility with the majority of SQLServer instances

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:

optionsBuilder.UseSqlServer(connectionString, opt=>opt.Use2017Functions());

A bit more general:

optionsBuilder.UseSqlServer(connectionString, opt=>opt.Use2017Features());

or even shorter:

optionsBuilder.UseSqlServer2017(connectionString);

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to concatenate multiple strings (C# Guide)
Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator.
Read more >
Using LINQ to concatenate strings
So you can one line this: List<string> strings = new List<string>() { "one", "two", "three" }; string concat = strings . Aggregate(new ...
Read more >
A Few Different Ways to Concatenate Strings in C# - ...
In this quick tutorial, we are going to talk about different ways to concatenate strings. Splitting and joining strings are commonly used ...
Read more >
How to concatenate localized strings mindfully
Previous experience has taught us to look for at least three types of translation errors when concatenating externalized strings: incorrect word ...
Read more >
String.prototype.concat() - JavaScript - MDN Web Docs
The concat() method of String values concatenates the string arguments to this string and returns a new string.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found