When generating code for the Entity Framework with T4, you sometimes have to put a name in singular or in plural (eg GetCustomer, GetAllCustomers). This can be complicated to implement because of the numerous exceptions (ex: man, men, child, children, …). But once again Microsoft offers us a tool (at least for the English language): PluralizationService. You can use it very easily:
PluralizationService pluralizationService = PluralizationService.CreateService(new CultureInfo("en")); Console.WriteLine(pluralizationService.Pluralize("man"));
Note that there are other free libraries that do the same thing. For example, CodeFluent Runtime allows you to manage French and English with the class
Do you have a question or a suggestion about this post? Contact me!