Home
Options

Why do I have to fully-qualify some (but not all) references in subqueries?

For example, I have a subquery which is set to use an EF Data connection which has a table called Series and a class of the same name

For a trivial example,

void Main()
{       
}

public int CountSeries()
{
    return Series.Count();
}

public Series GetFirstSeries()
{
    Series s= Series.FirstOrDefault();
    return s;
}

This compile correctly as a standalone program script, but even a main query as simple as

 #load ".\SubQuery"  

will fail to compile with the error with the error

Error in  ...\SubQuery.linq at line 10 ... CS0246 The type or namespace name 'Series' could not be found        

Line 10 is public Series GetFirstSeries()

If I change this method to be

public LINQPad.User.Series GetFirstSeries()
{
    LINQPad.User.Series s= Series.FirstOrDefault();
    return s;
}

It works fine.

But I don't need to fully-qualify Series.Count();. Why is this?

PS,
Just in case anyone else is as stupid as me, you might want to mention this on the https://www.linqpad.net/LinqReference.aspx page, as before I realised that fully-qualified names worked, I was using object in my subquery and casts in my main query.

Comments

Sign In or Register to comment.