I have just downloaded LinqPad to explore the benefits of using Linq queries in an application I am working on, however when I look at my database tables in the column on the left LinqPad displays all my tables with an 's' on the end, for instance CategoryTbl becomes CategoryTbls yet when I view my database in SQL management studio the table names appear correct.
Though any tables that should have an S on the end ie clients remain unchanged.
When I execute a Linq query I have to execute it against CategoryTbls but a SQL query has to be executed against CategoryTbl.
I was just wondering why this has happened, is it a bug or a feature? and if it is a feature why?
Thanks
The first question from the LINQPad FAQ:
Why does LINQPad pluralize table and child association properties? Can I switch this off?
Pluralizing child association properties (while keeping parent associations singular) makes for the most natural queries and is what Visual Studio does by default in building typed DataContexts.
To switch off pluralization, uncheck the "Pluralize" option when adding the database connection. (If the connection has already been created, right-click it to edit the connection properties).
This is also the standard behaviour of LINQ2SQL generated artifacts - the IEnumerables on the DataContext are [TableName]s and the Entity is [TableName]. So your linq queries would typically be something like.
List<Category> categoryList = context.Categories.Where(cat => somePredicateOnCat).ToList();
This usually makes for intuitive reading. Would you consider dropping the Hungarian 'tbl' suffix off your table naming standards?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With