Add a way of extending the autogenerated DataContext with partial classes
See this: http://stackoverflow.com/questions/24905706/how-to-extend-datamodel-in-linqpad-using-partial-classes
In a project I'm working on now, I've added a custom ToString() to a datatype in the datacontext, by using a partial class. The class I'm extending has a lot of foreign keys, including a one-to-many relationship. My custom ToString() fetches all the related objects and creates a single, userfriendly string for display, all on one line. If I could use LINQPad to inspect that table, it would make life so much easier. I mean, if I could add .Select(o => o.ToString()) to my queries, and have it use my own custom ToString.
But the specifics of that example are irrelevant, actually. Others might have other uses for this.
What we need is a way to get some of our own code into LINQPad in a place where it and the autogenerated datacontext can see each other, so the partial classes merge and create a greater, more useful, whole. Sounds nice, right ?
-
Erling Jacobsen commented
OK just thinking out loud (on the keyboard, as it were) here: To solve the specific problem I had, there should be a built-in way to "flatten" an object, by not displaying nested entities, but by chasing all foreign key relations to the end, and just displaying the end results of that.
But I'd rather have a way of extending the autogenerated datacontext, that seems much more general and powerful to me ...