LiteDB BsonExpression:有没有返回true的方法?

问题描述 投票:0回答:1

我对 LiteDB 还很陌生。在我尝试使用逻辑“and”结合的不同字段的部分比较组合来创建或多或少复杂的查询时,我使用了 LiteDB 的 Query.And() 方法,例如

// This is what I am missing!
BsonExpression  be  = BsonExpression.True;

if (!String.IsNullOrEmpty(property1))
{
   be  = Query.And(be, Query.EQ("Property1", property1));
}

if (!String.IsNullOrEmpty(property2))
{
   be  = Query.And(be, Query.EQ("Property2", property2));
}
// ...etc

我的意思是,是否有可能在 BsonExpression 或其他地方有一个正确的方法返回“true”?

bson litedb
1个回答
0
投票

BsonExpression be = BsonExpression.Create("0 = 0");

© www.soinside.com 2019 - 2024. All rights reserved.