In .net 3.5 if I generate a linq to sql data context, it does some wonderful magic to pluralize names. In my code I need to pluralize some terms. Can I use whatever method Linq is using to generate my plurals?
You'd have to use reflector to dig into the visual studio assemblies that do the code generation for the linq-to-sql designer.
LINQ to SQL doesn't expose its pluralization logic. A quick check with Reflector reveals that it's not using a terribly complex algorithm though:
If it ends with 'x', 'ch', 'sh' or 'ss', then add 'es'.
If it ends with 'y' preceded by a consonant, remove the y and add 'ies'.
Otherwise, add 's'.
If .NET 4 is an option, then EF's PluralizationService is much more thorough. Just in case you ever need to pluralize 'pneumonoultramicroscopicsilicovolcanoconiosis'.
There's also a .NET port of Inflector which does the same job. The author's blog is now down but it's available at http://cid-net.googlecode.com/svn/trunk/src/Cid.Mvc/Inflector.cs amongst others.
(via http://stackoverflow.com/questions/2552816/alternatives-to-inflector-net/2553071#2553071)
LINQ to SQL uses a fairly simple system for pluralization. If you are going to be working with complex terms, I recommend you use something like the Inflector that is part of SEDE. That piece of code seems to originate from the SubSonic project.