1
Vote

Doesn't work in VB.NET

description

If you convert the examples or unit tests over to vb.net you'll get errors when it tries to parse the lambda query:

"variable 'u' of type LdapUsers referenced from scope '', but it is not defined" linq

comments

BenRunnels wrote Aug 13, 2015 at 1:05 PM

I created a VB test project and converted over the mock and DirectoryContextPassiveTests to verify and I'm seeing the same result.
Test method VB.System.Directory.Services.Linq.v4._5.Tests.System.DirectoryServices.Linq.Tests.DirectoryContextPassiveTests.WhereUserFirstNameIsStephenTest threw exception: 

System.InvalidOperationException: variable 'u' of type 'VB.System.Directory.Services.Linq.v4._5.Tests.System.DirectoryServices.Linq.Tests.Mocks.User' referenced from scope '', but it is not defined
    at System.Linq.Expressions.Compiler.VariableBinder.Reference(ParameterExpression node, VariableStorageKind storage)
   at System.Linq.Expressions.Compiler.VariableBinder.VisitParameter(ParameterExpression node)
   at System.Linq.Expressions.ParameterExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.ExpressionVisitor.VisitMember(MemberExpression node)
   at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)
   at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes)
   at System.Linq.Expressions.Compiler.VariableBinder.VisitLambda(Expression`1 node)
   at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.Compiler.VariableBinder.Bind(LambdaExpression lambda)
   at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator)
   at System.Linq.Expressions.LambdaExpression.Compile()
   at System.DirectoryServices.Linq.QueryTranslator.VisitBinaryMemberAccess(AttributeBuilder builder, BinaryExpression binary, FilterOperator filterOperator) in QueryTranslator.cs: line 272