1
Vote

Included Test Examples Do Not Work

description

This is one of the test cases (ported to run in a console project for quick testing):

        var builder = new StringBuilder();
        var context = new TextContext<Book>(new StringWriter(builder));

        var query = from book in context
                    select book;

Console.WriteLine(query.Count());

This generates an error: "Error 41 Could not find an implementation of the query pattern for source type 'LinqExtender.Tests.TextContext<LinqExtender.Tests.Book>'. 'Select' not found."

Not sure what you were thinking, but a proper provider implementation is required before this LINQ should work...?

comments

mehfuzh wrote Dec 17, 2010 at 12:04 PM

Hi James,
Executing the query, it will just populate the builder. Here query.Count() will be 0, since in the query context i am returning an empty list. The purpose of the test project is to assert if the query is generated as it is expected. But yes it should not throw such exception as well. Therefore, i will take a look. Just to be sure, i guess you are using the version from github (source / download) not the one from source tab.

Sorry for any inconvenience

mehfuzh wrote Dec 17, 2010 at 12:06 PM

Also, if possible please try running the test project directly by using Test Driven .Net within visual studio.

mehfuzh wrote Dec 17, 2010 at 12:20 PM

Accordingly, I created an console project referenced LinqExtender.Tests (Since i will be using the bits from the test project) and LinqExtender project and wrote the following:

var builder = new StringBuilder();
        var context = new TextContext<Book>(new StringWriter(builder));

        var query = from book in context
                    select book;

        Console.WriteLine(query.Count());
        Console.WriteLine(builder);
        Console.ReadLine();
It prints :
0
select * from book

Here is the link for github project:
http://mehfuzh.github.com/LinqExtender/


Hope that helps,

warloki wrote Nov 30, 2012 at 3:20 PM

Have the same issue. I cannot understand its nature.
I have absolutely identical context classes: TextContext<T> : ExpressionVisitor, IQueryContext<T>
One is from the source code test project, another one created by myself.
In case when building my class I have the same error message.
Looks like my compiler cannot understand how the context could enumerate the items.

warloki wrote Nov 30, 2012 at 4:00 PM

After a few hours of struggling I finally found an answer.
I'm not so familiar with CLR to explain the behaviour.
Maybe you could help.
The error was disappeared after I changed the namespace of the TextContext to start with 'LinqExtender' and do the same with Test class where the context was queried.

You could reproduce the issue. Just change the namespace of the Test project and containing classes to something different from 'LinqExtender.XXX'.

warloki wrote Nov 30, 2012 at 4:17 PM

Forgot all my previous messages.
As I understand now the static extension methods exists in the LinqExtender namespace. And I just forgot to add using in my test class.