Home

CS0103 The name 'Invoices' does not exist in the current context

This simple code has a Connection to the Demo Database:

void Main()
{
var q = from i in Invoices select i;
Console.WriteLine(q.Count());

TestNS.TestClass.DoIt();

}
namespace TestNS
{
class TestClass
{
public static void DoIt()
{
var q = from i in Invoices select i;
Console.WriteLine(q.Count());
}
}
}

While the object for table Invoices is valid in Main, it is not valid in TestNS/TestClass/DoIt. Why is it? How can I make it valid in this context?

Thanks.

Comments

  • void Main()
    {
        var q = from i in Invoices select i;
        Console.WriteLine (q.Count());
    
        TestNS.TestClass.DoIt (this);
    }
    namespace TestNS
    {
        class TestClass
        {
            public static void DoIt (UserQuery query)
            {
                var q = from i in query.Invoices select i;
                Console.WriteLine (q.Count());
            }
        }
    }
    
Sign In or Register to comment.