[英]How to ignore case when using filters with the mongo driver in dot net core with C#
I have an aggregates pipeline query as below:我有一个聚合管道查询,如下所示:
string [] sids = { array of Student ids here };
string deptName = "math";
var pipeline = new BsonDocument[]
{
new BsonDocument("$match",
new BsonDocument
{
{"studentid", new BsonDocument("$in",BsonArray.Create(sids))},
{"dept",BsonRegularExpression.Create(new Regex( dept, RegexOptions.IgnoreCase))}
}
),
new BsonDocument("$sort",new BsonDocument("CardSwipeTimestamp", -1)),
new BsonDocument("$group",
new BsonDocument{
{ "_id",
new BsonDocument
{
{ "studentid","$studentid" },
{ "dept","$dept"}
}
},
{ "Status",new BsonDocument("$first", "$Status")},
{ "CardSwipeTimestamp",new BsonDocument("$first", "$CardSwipeTimestamp")}
}
),
new BsonDocument("$project",
new BsonDocument
{
{ "_id", 0 },
{ "studentid", "$_id.studentid" },
{ "dept", "$_id.dept" },
{ "Status", "$Status" },
{ "CardSwipeTimestamp", "$CardSwipeTimestamp" }
}
),
new BsonDocument("$skip",0),
new BsonDocument("$limit",3),
};
collectionName.Aggregate<BsonDocument>(pipeline).ToList()
These only returns a value if the department passed in matches the case of what is stored in the collection.如果传入的部门与集合中存储的内容匹配,则这些仅返回一个值。
How to ignore the case of the incoming parameter when doing a search using the above query?使用上述查询进行搜索时如何忽略传入参数的大小写?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.