Discussion:
[mongodb-user] Linq: Command find failed: $and/$or/$nor must be a nonempty array
Michael Krog
2018-11-19 10:32:28 UTC
Permalink
I am trying to create a dynamic Linq expression for searching in Mongo. But
no matter what I do it fails.

I do it like this:
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text) ||
e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()


But I always get this error:
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1 responseHandling,
Boolean slaveOk, IBsonSerializer`1 resultSerializer, MessageEncoderSettings
messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(
IChannelSource channelSource, ICoreSessionHandle session, ReadPreference
readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](
Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ec25eb34-ba2b-4a35-80a0-8425c115ca71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Fabio
2018-11-20 21:43:40 UTC
Permalink
you use regex and builders, is faster.
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text)
|| e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle session
, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](
Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/ec25eb34-ba2b-4a35-80a0-8425c115ca71%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/ec25eb34-ba2b-4a35-80a0-8425c115ca71%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAJr6rmHFEePc6yGucZbeauD7x5%2BCgS2m3LiRZkBDyeQ8CjdE5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael Krog
2018-11-23 14:49:35 UTC
Permalink
Thanks.

But it won't help me build dynamic queries which is what I am aiming at!

- Michael
Post by Fabio
you use regex and builders, is faster.
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text)
|| e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](
Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/ec25eb34-ba2b-4a35-80a0-8425c115ca71%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-user/ec25eb34-ba2b-4a35-80a0-8425c115ca71%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c218744b-9428-4814-8298-e5cd187cc824%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-20 23:18:11 UTC
Permalink
Hi!

You should post your MongoDB version, your driver version, and a few
example documents.

Can you state in English exactly what you want to query for? Often, if you
can precisely write down in every day language what you want to do, it is
an enormous help in coding the actual query.

Thanks so much

Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text)
|| e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle session
, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](
Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/84d4f287-d65f-44d3-89f0-fb3f02b305cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Krog
2018-11-23 14:48:44 UTC
Permalink
Hi.

I am running Mongo 3.6 (from the official docker image
at https://hub.docker.com/_/mongo/).
I have tried with 2 driver versions: 2.5.1 and 2.7.2. Same result.

The following is an example of a document:
{
"_id" : ObjectId("1234567890abcdef12345678"),
"CreatedBy" : null,
"CreatedDate" : Date(-62135596800000),
"LastModifiedBy" : null,
"LastModifiedDate" : ISODate("2018-11-19T14:00:11.021Z"),
"ItemTypeId" : "5bf2c1ebef99252d6dc4f849",
"Title" : "Item title",
"Description" : "This is a description",
"Permissions" : {},
"Attributes" : {
"gender" : "Female",
"dateOfBirth" : "c. January 1, 1912"
},
"Status" : 0,
"Notes" : [
{
"Title" : "A title",
"Content" : "Some content",
"_id" : "note_1"
},
{
"Title" : "Another title",
"Content" : "Some other content",
"_id" : "note_2"
}
]
}


In plain english, I want to be able to search for documents in mongo using
any predicate of type
*System.Linq.Expressions.Expression<Func<IndexItem, bool>>.*.
I am building a REST api using .NET Core MVC that accepts parameters for
building the predicate. For this to work, I need to be able to query
documents using a *System.Linq.Expressions.Expression<Func<IndexItem, bool>>
predicate.* But I am unable to get even the most simple and static
predicate to work without getting the mentioned error. :-(

- Michael
Post by Robert Cochran
Hi!
You should post your MongoDB version, your driver version, and a few
example documents.
Can you state in English exactly what you want to query for? Often, if you
can precisely write down in every day language what you want to do, it is
an enormous help in coding the actual query.
Thanks so much
Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text)
|| e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](
Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/f8152749-5168-4135-ad94-e6014b66c672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-23 19:29:19 UTC
Permalink
When I look up the Docker tags for mongo, it seems to me that you are using
either the 3.6.9-stretch tag or the 3.6-windowsservercore tag. Which exact
tag are you using, and what is your host operating system?

Thanks so much

Bob
Hi.
I am running Mongo 3.6 (from the official docker image at
https://hub.docker.com/_/mongo/).
I have tried with 2 driver versions: 2.5.1 and 2.7.2. Same result.
{
"_id" : ObjectId("1234567890abcdef12345678"),
"CreatedBy" : null,
"CreatedDate" : Date(-62135596800000),
"LastModifiedBy" : null,
"LastModifiedDate" : ISODate("2018-11-19T14:00:11.021Z"),
"ItemTypeId" : "5bf2c1ebef99252d6dc4f849",
"Title" : "Item title",
"Description" : "This is a description",
"Permissions" : {},
"Attributes" : {
"gender" : "Female",
"dateOfBirth" : "c. January 1, 1912"
},
"Status" : 0,
"Notes" : [
{
"Title" : "A title",
"Content" : "Some content",
"_id" : "note_1"
},
{
"Title" : "Another title",
"Content" : "Some other content",
"_id" : "note_2"
}
]
}
In plain english, I want to be able to search for documents in mongo using
any predicate of type
*System.Linq.Expressions.Expression<Func<IndexItem, bool>>.*.
I am building a REST api using .NET Core MVC that accepts parameters for
building the predicate. For this to work, I need to be able to query
documents using a *System.Linq.Expressions.Expression<Func<IndexItem, bool>>
predicate.* But I am unable to get even the most simple and static
predicate to work without getting the mentioned error. :-(
- Michael
Post by Robert Cochran
Hi!
You should post your MongoDB version, your driver version, and a few
example documents.
Can you state in English exactly what you want to query for? Often, if
you can precisely write down in every day language what you want to do, it
is an enormous help in coding the actual query.
Thanks so much
Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text
) || e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken
)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken
)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult
](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/3d7e53ba-f4ef-4d72-b3ef-16dbb863ed33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-25 03:57:28 UTC
Permalink
I've spent a big part of my holiday period learning Docker. How did you get
.NET Core installed? Did you customize a Dockerfile and build from it, and
then run the resulting Docker image? How are you persisting the MongoDB
data?

Thanks so much

Bob
Post by Robert Cochran
When I look up the Docker tags for mongo, it seems to me that you are
using either the 3.6.9-stretch tag or the 3.6-windowsservercore tag. Which
exact tag are you using, and what is your host operating system?
Thanks so much
Bob
Hi.
I am running Mongo 3.6 (from the official docker image at
https://hub.docker.com/_/mongo/).
I have tried with 2 driver versions: 2.5.1 and 2.7.2. Same result.
{
"_id" : ObjectId("1234567890abcdef12345678"),
"CreatedBy" : null,
"CreatedDate" : Date(-62135596800000),
"LastModifiedBy" : null,
"LastModifiedDate" : ISODate("2018-11-19T14:00:11.021Z"),
"ItemTypeId" : "5bf2c1ebef99252d6dc4f849",
"Title" : "Item title",
"Description" : "This is a description",
"Permissions" : {},
"Attributes" : {
"gender" : "Female",
"dateOfBirth" : "c. January 1, 1912"
},
"Status" : 0,
"Notes" : [
{
"Title" : "A title",
"Content" : "Some content",
"_id" : "note_1"
},
{
"Title" : "Another title",
"Content" : "Some other content",
"_id" : "note_2"
}
]
}
In plain english, I want to be able to search for documents in mongo
using any predicate of type
*System.Linq.Expressions.Expression<Func<IndexItem, bool>>.*.
I am building a REST api using .NET Core MVC that accepts parameters for
building the predicate. For this to work, I need to be able to query
documents using a *System.Linq.Expressions.Expression<Func<IndexItem, bool>>
predicate.* But I am unable to get even the most simple and static
predicate to work without getting the mentioned error. :-(
- Michael
Post by Robert Cochran
Hi!
You should post your MongoDB version, your driver version, and a few
example documents.
Can you state in English exactly what you want to query for? Often, if
you can precisely write down in every day language what you want to do, it
is an enormous help in coding the actual query.
Thanks so much
Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(
text) || e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult
](ICoreSession session, ReadPreference readPreference,
DatabaseNamespace databaseNamespace, BsonDocument command,
IElementNameValidator commandValidator, BsonDocument additionalOptions,
Func`1 responseHandling, Boolean slaveOk, IBsonSerializer`1
resultSerializer, MessageEncoderSettings messageEncoderSettings,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken
cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken
cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult
](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/fd6afa56-3d2e-427f-a6e0-84e812a9d322%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-11-26 22:15:36 UTC
Permalink
I will say this: it is extremely difficult to take a mongo/3.6 Dockerfile
from e.g. GitHub
<https://github.com/docker-library/mongo/blob/cb722bcc413b6789064d874b5231f9e23cc81540/3.6/Dockerfile>,
and customize that Dockerfile on your local machine, and then build a new
container that will actually work. The logic for verifying the gpg keys is
flawed because it is trying to extract keys from ha.pool.sks-keyservers.net instead
of ipv4.pool.sks-keyservers.net and results in strange gnupg errors that
then kill the entire chain of operations in that Docker command. Sometimes
the logic works, sometimes not. Then even if you build it correctly, a
'docker run' on the container can fail due to permission errors on the one
COPY command in this Dockerfile. The error messages are pretty unfriendly
and don't hint to the cause. (Maybe one needs to chown the
'docker-entrypoint.sh' script so that root owns it?) In total, the
Dockerfile is flawed and I'm not quite sure how the original developer was
able to build and test a container successfully from it. It could be that
my host machine (Ubuntu 18.04.1 LTS) has some quirks to it that the
original developer didn't have to work around.

I recognize that I don't know much about Docker -- indeed, this weekend was
a deep dive for me in coding Dockerfiles. And researching gnupg, too.

So to test out Michael's problem I think a Vagrant box might help. I could
be just way too accustomed to Vagrant and VirtualBox, but I like them...

Bob
Hi.
I am running Mongo 3.6 (from the official docker image at
https://hub.docker.com/_/mongo/).
I have tried with 2 driver versions: 2.5.1 and 2.7.2. Same result.
{
"_id" : ObjectId("1234567890abcdef12345678"),
"CreatedBy" : null,
"CreatedDate" : Date(-62135596800000),
"LastModifiedBy" : null,
"LastModifiedDate" : ISODate("2018-11-19T14:00:11.021Z"),
"ItemTypeId" : "5bf2c1ebef99252d6dc4f849",
"Title" : "Item title",
"Description" : "This is a description",
"Permissions" : {},
"Attributes" : {
"gender" : "Female",
"dateOfBirth" : "c. January 1, 1912"
},
"Status" : 0,
"Notes" : [
{
"Title" : "A title",
"Content" : "Some content",
"_id" : "note_1"
},
{
"Title" : "Another title",
"Content" : "Some other content",
"_id" : "note_2"
}
]
}
In plain english, I want to be able to search for documents in mongo using
any predicate of type
*System.Linq.Expressions.Expression<Func<IndexItem, bool>>.*.
I am building a REST api using .NET Core MVC that accepts parameters for
building the predicate. For this to work, I need to be able to query
documents using a *System.Linq.Expressions.Expression<Func<IndexItem, bool>>
predicate.* But I am unable to get even the most simple and static
predicate to work without getting the mentioned error. :-(
- Michael
Post by Robert Cochran
Hi!
You should post your MongoDB version, your driver version, and a few
example documents.
Can you state in English exactly what you want to query for? Often, if
you can precisely write down in every day language what you want to do, it
is an enormous help in coding the actual query.
Thanks so much
Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(text
) || e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](
ICoreSession session, ReadPreference readPreference, DatabaseNamespace
databaseNamespace, BsonDocument command, IElementNameValidator
commandValidator, BsonDocument additionalOptions, Func`1
responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer,
MessageEncoderSettings messageEncoderSettings, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken cancellationToken
)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken cancellationToken
)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult
](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/976ae72a-cd77-4d05-b66e-8495eb271727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robert Cochran
2018-12-01 18:30:49 UTC
Permalink
Michael -- can you provide a Dockerfile and the complete query you are
doing through C#?

Thanks

Bob
Post by Robert Cochran
I will say this: it is extremely difficult to take a mongo/3.6 Dockerfile
from e.g. GitHub
<https://github.com/docker-library/mongo/blob/cb722bcc413b6789064d874b5231f9e23cc81540/3.6/Dockerfile>,
and customize that Dockerfile on your local machine, and then build a new
container that will actually work. The logic for verifying the gpg keys is
flawed because it is trying to extract keys from
ha.pool.sks-keyservers.net instead of ipv4.pool.sks-keyservers.net and
results in strange gnupg errors that then kill the entire chain of
operations in that Docker command. Sometimes the logic works, sometimes
not. Then even if you build it correctly, a 'docker run' on the container
can fail due to permission errors on the one COPY command in this
Dockerfile. The error messages are pretty unfriendly and don't hint to the
cause. (Maybe one needs to chown the 'docker-entrypoint.sh' script so that
root owns it?) In total, the Dockerfile is flawed and I'm not quite sure
how the original developer was able to build and test a container
successfully from it. It could be that my host machine (Ubuntu 18.04.1 LTS)
has some quirks to it that the original developer didn't have to work
around.
I recognize that I don't know much about Docker -- indeed, this weekend
was a deep dive for me in coding Dockerfiles. And researching gnupg, too.
So to test out Michael's problem I think a Vagrant box might help. I could
be just way too accustomed to Vagrant and VirtualBox, but I like them...
Bob
Hi.
I am running Mongo 3.6 (from the official docker image at
https://hub.docker.com/_/mongo/).
I have tried with 2 driver versions: 2.5.1 and 2.7.2. Same result.
{
"_id" : ObjectId("1234567890abcdef12345678"),
"CreatedBy" : null,
"CreatedDate" : Date(-62135596800000),
"LastModifiedBy" : null,
"LastModifiedDate" : ISODate("2018-11-19T14:00:11.021Z"),
"ItemTypeId" : "5bf2c1ebef99252d6dc4f849",
"Title" : "Item title",
"Description" : "This is a description",
"Permissions" : {},
"Attributes" : {
"gender" : "Female",
"dateOfBirth" : "c. January 1, 1912"
},
"Status" : 0,
"Notes" : [
{
"Title" : "A title",
"Content" : "Some content",
"_id" : "note_1"
},
{
"Title" : "Another title",
"Content" : "Some other content",
"_id" : "note_2"
}
]
}
In plain english, I want to be able to search for documents in mongo
using any predicate of type
*System.Linq.Expressions.Expression<Func<IndexItem, bool>>.*.
I am building a REST api using .NET Core MVC that accepts parameters for
building the predicate. For this to work, I need to be able to query
documents using a *System.Linq.Expressions.Expression<Func<IndexItem, bool>>
predicate.* But I am unable to get even the most simple and static
predicate to work without getting the mentioned error. :-(
- Michael
Post by Robert Cochran
Hi!
You should post your MongoDB version, your driver version, and a few
example documents.
Can you state in English exactly what you want to query for? Often, if
you can precisely write down in every day language what you want to do, it
is an enormous help in coding the actual query.
Thanks so much
Bob
Post by Michael Krog
I am trying to create a dynamic Linq expression for searching in Mongo.
But no matter what I do it fails.
Expression<Func<IndexItem, bool>> predicate = e => e.Title.Contains(
text) || e.Description.Contains(text);
var q = collection.AsQueryable<T>().Where(predicate);
List list=q.toList()
MongoDB.Driver.MongoCommandException: Command find failed: $and/$or/$nor
must be a nonempty array.
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.ProcessReply(ConnectionId
connectionId, ReplyMessage`1 reply)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection
connection, CancellationToken cancellationToken)
at
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`
1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult
](ICoreSession session, ReadPreference readPreference,
DatabaseNamespace databaseNamespace, BsonDocument command,
IElementNameValidator commandValidator, BsonDocument additionalOptions,
Func`1 responseHandling, Boolean slaveOk, IBsonSerializer`1
resultSerializer, MessageEncoderSettings messageEncoderSettings,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle
channel, ICoreSessionHandle session, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`
1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle
session, ReadPreference readPreference, CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindCommandOperation`1.Execute(
IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.FindOperation`1.Execute(IReadBinding
binding, CancellationToken cancellationToken)
at
MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding
binding, IReadOperation`1 operation, CancellationToken
cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, ReadPreference readPreference,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle
session, IReadOperation`1 operation, CancellationToken
cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](IClientSessionHandle
session, FilterDefinition`1 filter, FindOptions`2 options,
CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult
](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.FindSync[TProjection](
FilterDefinition`1 filter, FindOptions`2 options, CancellationToken
cancellationToken)
at MongoDB.Driver.FindFluent`2.ToCursor(CancellationToken
cancellationToken)
at MongoDB.Driver.Core.Operations.AsyncCursorSourceEnumerableAdapter`
1.GetEnumerator()
at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1
enumerable)
at System.Collections.Generic.List`1.InsertRange(Int32 index,
IEnumerable`1 collection)
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/d8ba5165-6026-4456-820d-39d1cd8cecd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...