25

Possible Duplicate:
Pluralize - Singularize

The C# 4.0 (maybe older versions, but I've only tested with 4.0) Linq-to-SQL generator will pluralize your table names; even tough plurals like Territory. It knows that Territories is the plural. Is there anyway to access this pluralization function?

Community
  • 1
  • 1
Geoff
  • 253
  • 2
  • 4

2 Answers2

16

System.Data.Entity.Design.PluralizationServices.PluralizationService

EDIT Linking the (older) answer in the (older) question, as eglasias suggests. Go forth and upvote, he deserves the rep.

Community
  • 1
  • 1
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • 2
    Why are there more upvotes for my answer than people voting to mark the question as a duplicate? – Ben Voigt Sep 17 '10 at 02:24
  • Because it's a whole lot easier to click on the "good answer" button? There's no "mark as duplicate" button immediately visible. – Jim Mischel Sep 17 '10 at 02:33
  • 2
    Because the second mouse gets the cheese. In the old post, Daniel gave the same answer, got 1 upvote, and has 86 reputation at the time that this is being written. Life can be SO unfair. – Windows programmer Sep 17 '10 at 03:19
  • 3
    Come on. Obviously it’s because only like 1% of SO users have enough rep to vote to close. – Timwi Sep 17 '10 at 03:28
  • @Timwi Wow, your approximation was spot on. 1.44% to be more exact. – NullUserException Sep 17 '10 at 03:32
  • @Ben: because I don't think it's a duplicate, since it is about the LINQ to SQL algorithm, not just general. – John Saunders Sep 17 '10 at 03:49
  • 1
    There, 1 more vote to close as duplicate without voting for this answer / also 1 more vote to the answer in the other/original question. imho when doing this you should always link to the other answer as well in here. – eglasius Sep 17 '10 at 07:01
  • @Ben Voigt, possibly because you linked to the documentation and he just gave class name. He'll learn. – RBerteig Sep 17 '10 at 07:32
  • @John: It is a duplicate because the requirement for being closed as a duplicate is that the question has been fully covered by an earlier question, not that both questions have identical scope. The other question and answers completely cover this one. – Ben Voigt Sep 17 '10 at 13:26
  • @Ben: I didn't see Daniel's answer first time. Voted to close. Also, upvoted Daniel's answer and edited it to include link to documentation. – John Saunders Sep 17 '10 at 14:29
0

I'm not sure the Linq to SQL inflector is publicly accessible, but if you need an inflector you could use SubSonic's inflector, NCommon, uNhAddins, Castle ActiveRecord, etc.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275