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
I'm sorry, I can't reproduce this. Do you have the connection set the same in both queries?
I do, but this is a using a DataContext in my own custom assembly, so perhaps I have messed up somewhere as I can't replicate it on other connections using the 'build data context automatically' option.