Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"A mongo field must be a part of the Contains method." when querying using Id property #40

Open
Kostassoid opened this issue Nov 28, 2011 · 2 comments

Comments

@Kostassoid
Copy link

When querying something like:

experts.Where(e => authorsIds.Contains(e.Id)).ToList()

where experts is a fluent-mongo Queryable collection and authorsIds is just some List.

Id is declared as

public Guid Id { get; protected set; }

I'm getting:

FluentMongo.Linq.InvalidQueryException : A mongo field must be a part of the Contains method.
at FluentMongo.Linq.Translators.BsonDocumentFormatter.VisitMethodCall(MethodCallExpression m) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\Translators\BsonDocumentFormatter.cs: line 196
at FluentMongo.Linq.Expressions.ExpressionVisitor.Visit(Expression exp) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\Expressions\ExpressionVisitor.cs: line 62
at FluentMongo.Linq.Translators.MongoQueryObjectBuilder.VisitSelect(SelectExpression select) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\Translators\MongoQueryObjectBuilder.cs: line 81
at FluentMongo.Linq.Translators.MongoQueryObjectBuilder.VisitProjection(ProjectionExpression projection) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\Translators\MongoQueryObjectBuilder.cs: line 87
at FluentMongo.Linq.Translators.MongoQueryObjectBuilder.Build(Expression expression) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\Translators\MongoQueryObjectBuilder.cs: line 19
at FluentMongo.Linq.ExecutionBuilder.VisitProjection(ProjectionExpression projection) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\ExecutionBuilder.cs: line 21
at FluentMongo.Linq.MongoQueryProvider.Execute(Expression expression) in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\MongoQueryProvider.cs: line 98
at FluentMongo.Linq.MongoQuery1.GetEnumerator() in D:\Projects\ExternalLibs\fluent-mongo\src\FluentMongo\Linq\MongoQuery.cs: line 102 at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList(IEnumerable1 source)
....

@Kostassoid
Copy link
Author

Update: authorsIds in example above was a List of Nullable Guids! when changed to simple Guids everything worked fine. Don't know if it's an issue anymore.

@craiggwilson
Copy link
Owner

Sounds like we aren't handling nullable types very well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants