mehfuzh / LinqExtender

LinqExtender is a toolkit for building custom providers.

Home Page:http://mehfuzh.github.com/LinqExtender/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyNotFoundException when querying over object property that has no setter

vorotech opened this issue · comments

Hello,

Here is the stack trace.
The issue can be reproduced if remove setter from the Book class in the LinqExteneder Test project.

System.Collections.Generic.KeyNotFoundException was unhandled by user code
HResult=-2146232969
Message=The given key was not present in the dictionary.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at LinqExtender.Query1.FillBucket(BucketImpl bucket, PropertyInfo info, Object value, MemberExpression memberExpression) in C:\Source\LinqExtender\Source\Query.cs:line 1038
at LinqExtender.Query1.ExtractDataFromExpression(BucketImpl bucket, Expression left, Expression right) in C:\Source\LinqExtender\Source\Query.cs:line 924 at LinqExtender.Query1.ProcessBinaryResult(Expression expression) in C:\Source\LinqExtender\Source\Query.cs:line 748
at LinqExtender.Query1.VisitBinary(BinaryExpression expression) in C:\Source\LinqExtender\Source\Query.cs:line 568 at LinqExtender.ExpressionVisitor.Visit(Expression expression) in C:\Source\LinqExtender\Source\ExpressionVisitor.cs:line 63 at LinqExtender.ExpressionVisitor.VisitLamda(LambdaExpression lambdaExpression) in C:\Source\LinqExtender\Source\ExpressionVisitor.cs:line 139 at LinqExtender.ExpressionVisitor.Visit(Expression expression) in C:\Source\LinqExtender\Source\ExpressionVisitor.cs:line 28 at LinqExtender.Query1.VisitMethodCall(MethodCallExpression expression) in C:\Source\LinqExtender\Source\Query.cs:line 662
at LinqExtender.ExpressionVisitor.Visit(Expression expression) in C:\Source\LinqExtender\Source\ExpressionVisitor.cs:line 65
at LinqExtender.Query1.CreateQuery[TS](Expression expression) in C:\Source\LinqExtender\Source\Query.cs:line 154 at LinqExtender.Queryable.CreateQuery[TSource,TResult,TDelegate](IQueryContext1 source, MethodInfo methodInfo, Expression1 expression, Type[] genArgs) in C:\Source\LinqExtender\Source\Queryable.cs:line 70 at LinqExtender.Queryable.Where[TSource](IQueryContext1 source, Expression`1 predicate) in C:\Source\LinqExtender\Source\Queryable.cs:line 18
at LinqExtender.TFS.Tests.WorkItemContextTest.SimpleWhereExpression() in

I understood why it happened and looks like it is as designed. The behavior can be changed only after applying a dynamic proxy instead of class generator (that's mean switching to .net4) and rewritung a bit of logic inside the LinqExtender assembly.
I forked a code and will try to play this it.