简体   繁体   English

MongoDb c#driver 2.0 BsonNull用法

[英]MongoDb c# driver 2.0 BsonNull usage

I have isDeleted Nullable property in Profile class. 我在Profile类中有isDeleted Nullable属性。

Builders<Profile>.Filter.Eq(p => p.IsDeleted, BsonNull.Value)

But the following code raised next compilation error: 但是下面的代码引发了下一个编译错误:

Error 11    Cannot convert lambda expression to type 
'MongoDB.Driver.FieldDefinition<MongoDB.DataTypes.Profile,MongoDB.Bson.BsonNull>' 
because it is not a delegate type   

How to implement a null-check ? 如何实现空检查?

如果IsDeleted为空,那么在查询时可以使用简单的null而不是BsonNull.Value

Builders<Profile>.Filter.Eq(p => p.IsDeleted, null)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM