The query is innocent:

Query.All<RowLevelPermission>().ToArray()

But it gets:

System.NullReferenceException occurred
  Message=Object reference not set to an instance of an object.
  Source=Xtensive.Storage
  StackTrace:
       at Xtensive.Storage.Linq.Queryable`1.GetEnumerator() in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\Queryable.cs:line 77
  InnerException:

If i use debugger and try to evaluate my Query.All() when the exception is thrown I can see this:

Unable to translate 'Query.All()' expression. See inner exception for details.
   at Xtensive.Storage.Linq.QueryProvider.Translate[TResult](Expression expression) in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\QueryProvider.cs:line 81
   at Xtensive.Storage.Linq.QueryProvider.Execute[TResult](Expression expression) in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\QueryProvider.cs:line 67
   at Xtensive.Storage.Linq.Queryable`1.GetEnumerator() in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\Queryable.cs:line 76
   at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()

And further:

Property 'ParameterizedQuery' is already initialized.
   at Xtensive.Storage.Internals.QueryCachingScope.set_ParameterizedQuery(TranslatedQuery value) in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Internals\QueryCachingScope.cs:line 36
   at Xtensive.Storage.Linq.Translator.Translate[TResult](ProjectionExpression projection, IEnumerable`1 tupleParameterBindings) in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\Translator.Materialization.cs:line 65
   at Xtensive.Storage.Linq.Translator.Translate[TResult]() in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\Translator.Materialization.cs:line 35
   at Xtensive.Storage.Linq.QueryProvider.Translate[TResult](Expression expression) in c:\Temp\DataObjects.Net\Xtensive.Storage\Xtensive.Storage\Linq\QueryProvider.cs:line 78

I still cannot figure out, why it works in other places and does not here.

asked Aug 26 '10 at 02:18

xumix's gravatar image

xumix
425757682

edited Sep 02 '10 at 10:40

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

I've found the problem, this query is executed deeply inside Query.ExecuteFutureScalar(,). If I remove ExecuteFutureScalar and just use methods directly, then it works OK.

(Aug 26 '10 at 02:35) xumix xumix's gravatar image
1

Only one query can be executed inside Query.ExecuteXxx methods. Was this condition violated?

(Aug 26 '10 at 02:50) Alex Yakunin Alex%20Yakunin's gravatar image

I suppose, that yes. Thanks for your solution.

(Aug 26 '10 at 02:56) xumix xumix's gravatar image

The question has been closed for the following reason "The question is answered, right answer was accepted" by Dmitri Maximov Aug 26 '10 at 03:20


One Answer:

Correct answer: only one query can be executed inside Query.ExecuteXxx methods. This condition was violated, since:

Query.All<RowLevelPermission>().ToArray() is executed deeply inside Query.ExecuteFutureScalar. If I remove ExecuteFutureScalar and just use methods directly, then it works OK.

answered Aug 26 '10 at 03:16

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

So, why such a strange exception is thrown? It looks like a bug in DataObjects...

(Aug 26 '10 at 03:49) Alex Kofman Alex%20Kofman's gravatar image

AFAIK, currently we don't have any special code detecting exactly this case, but the code we have will anyway fail. So it's not a bug, but absence of dedicated checks, that could help to detect improper usage of our API ("fool checks").

Let's ask Alexis Kochetov about this behavior.

(Aug 26 '10 at 04:07) Alex Yakunin Alex%20Yakunin's gravatar image

But anyway, why do you have such a limitation(1 query per ExecuteFutureXXX)?

(Sep 02 '10 at 05:37) xumix xumix's gravatar image

Yes, although I'm not sure if it's checked explicitly.

(Sep 02 '10 at 10:39) Alex Yakunin Alex%20Yakunin's gravatar image

Erm... I mean, why do u have this limitation at all?

(Sep 02 '10 at 10:53) xumix xumix's gravatar image

powered by OSQA