Can i use linq method for multiple expression?

In .net 3.5, if I create a linq to sql data context, it does wonderful magic for name pluralization. In my code, I need to pluralize some terms. Can I use any Linq method used to generate plurals?

+3
source share
4 answers

LINQ to SQL does not reveal its pluralization logic. A quick check with Reflector shows that it does not use a terribly complex algorithm:

If it ends with "x", "ch", "sh" or "ss", add "es".
If it ends in "y" preceded by a consonant, remove y and add "ies".
Otherwise add 's'.

If .NET 4 is an option, then the EF PluralizationService is much more thorough. Just in case, you will ever need to pluralize "pneumonutramcroscopic silicocanoconiosis."

+2
source

You will need to use a reflector to delve into the visual studio assemblies that generate the code for the linq-to-sql constructor.

+2
source

LINQ to SQL uses a fairly simple system for pluralization. If you intend to work with complex terms, I recommend that you use something like Inflector, which is part of SEDE . This piece of code seems to come from the SubSonic project .

0
source

Source: https://habr.com/ru/post/1760145/


All Articles