Can I dynamically reference multiple databases in a LINQPad script?
<p>I have a database with a table describing multiple entities, with one column being the name of another database holding data for that entity. All entity databases are on the same SQL Server as the one listing them and all have an identical schema.</p>

<p>I know that I can use Ctrl-drag to add the additional databases to my script but what I actually want is to do this dynamically from the database name. Something like this.</p>

<pre><code>var entities = ParentDatabase.EntityList
    .Where(e =&gt; ??)
    .Select(e =&gt; new { e.Id, e.DatabaseName });

var results = new List&lt;ResultCarrier&gt;();

foreach (var entity in entities)
{
    results.AddRange(
        GetDataContextFor(entity.DatabaseName).SomeTable
            .Select(t =&gt; new ResultCarrier() 
                { 
                    EntityId = e.Id, 
                    Column1 = t.Column1,
                    Column2 = t.Column2,
                    ... 
                }));
}

// further process combined results
</code></pre>

<p>Is this possible?</p>

<p>I see that the type of one of these databases is LINQPad.User.DatabaseNameTypes.TypedDataContext and wondered whether, as each database has the same schema, there might be a base class that I could use in some way to achieve this.</p>