Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB查询C#驱动程序_C#_Mongodb_Mongodb .net Driver_Bson - Fatal编程技术网

MongoDB查询C#驱动程序

MongoDB查询C#驱动程序,c#,mongodb,mongodb-.net-driver,bson,C#,Mongodb,Mongodb .net Driver,Bson,我在C#MongoDB中表达这个查询时遇到了问题,我希望它返回objectID的所有结果,其中它不等于“000000000000000000000000000000”,这在MongoVue中起作用;但我无法在我的程序中使用它 {"ProfilePictureId" : {$ne: new ObjectId ("000000000000000000000000")}} 我使用的是官方的C#driver: 您可以按如下方式构建查询: var query = Query.NE("ProfilePic

我在C#MongoDB中表达这个查询时遇到了问题,我希望它返回
objectID
的所有结果,其中它不等于
“000000000000000000000000000000”
,这在MongoVue中起作用;但我无法在我的程序中使用它

{"ProfilePictureId" : {$ne: new ObjectId ("000000000000000000000000")}}
我使用的是官方的C#driver:


您可以按如下方式构建查询:

var query = Query.NE("ProfilePictureId", ObjectId.Empty);

ObjectId.Empty
返回一个由全零组成的
ObjectId

您可以按如下方式构建查询:

var query = Query.NE("ProfilePictureId", ObjectId.Empty);

ObjectId.Empty
返回一个由全零组成的
ObjectId

假设您正在查询类似以下内容的类的文档:

public class Profile {
        public ObjectId ProfilePictureId { get; set; }
        //... other attributes, construcotrs, methods etc...
}
您还可以使用表达式lambdas编写查询,如下所示:

var query = Query<Profile>.NE(s => s.ProfilePictureId, ObjectId.Empty);
var query=query.NE(s=>s.ProfilePictureId,ObjectId.Empty);

假设您正在查询类似以下内容的类的文档:

public class Profile {
        public ObjectId ProfilePictureId { get; set; }
        //... other attributes, construcotrs, methods etc...
}
您还可以使用表达式lambdas编写查询,如下所示:

var query = Query<Profile>.NE(s => s.ProfilePictureId, ObjectId.Empty);
var query=query.NE(s=>s.ProfilePictureId,ObjectId.Empty);