Search code examples
c#linqpad

Finding out where some code in a LINQPad query is defined


I have the following C# code segment in a LINQPad query:

.Select(x => new LocationDistrict
    { ...

When I hover over LocationDistrict, the tooltip displays:

LINQPad.User.LocationDistrict

enter image description here

How can I find out where User.LocationDistrict is being pulled in from? In the right-click context menu, the Go to definition F12 option is greyed out.


Solution

  • TL;DR: LINQPad automatically generates classes based on tables in your connected database. The classes for rows in each table are placed in the LINQPad.User namespace.

    For instance, in the following examples I'm using the AdventureWorks2012 database. When I connect to it, I can see a number of "tables" in the Connection pane:

    Tables in AdventureWorks2012

    I can drag those over to the Query window and start a query:

    LINQ methods show up on tables

    The type of Addresses in this case is System.Data.Linq.Table<Address>, where Address is of type LINQPad.User.Address:

    Showing type of individual records is under LINQPad.User

    So, it appears as though LocationDistrict in your case is a mapping of an individual record in the table of a similar name. It would be called LocationDistricts in the Connection pane, but since LINQPad does some naming normalization, could be called LOCATION_DISTRICT in your actual database.

    I guess the makers of LINQPad needed some place to put these types (to avoid naming conflicts), and settled on LINQPad.User as an acceptable namespace.