Mongo c#query-聚合匹配如何传入语句以检查列表中是否存在uid<;字符串>;
您需要Mongo c#query-聚合匹配如何传入语句以检查列表中是否存在uid<;字符串>;,c#,mongodb,linq,C#,Mongodb,Linq,您需要Any()和Contains()在此处: var anonymousTypeList = mongoCollection.Aggregate().Match(c => c.Uid == ------).Group(key => new { Uid = key.Uid }, grou
Any()
和Contains()
在此处:
var anonymousTypeList = mongoCollection.Aggregate().Match(c => c.Uid == ------).Group(key => new
{
Uid = key.Uid
},
group => new { Key = group.Key, MinIndex = group.Min(p => p.Time), MaxIndex = group.Max(p => p.Time) })
.ToList();
结果和
string[] listUid = new [] { "abc", "def" };
// Then in the Match
.Match(c => c.listUid.Any(i => c.Uid.Contains(i));
甚至:
{ "$match": { "Uid": { "$in": ["abc", "def"] } } }
对于稍短一点的相同内容您需要Any()
和Contains()
在这里:
var anonymousTypeList = mongoCollection.Aggregate().Match(c => c.Uid == ------).Group(key => new
{
Uid = key.Uid
},
group => new { Key = group.Key, MinIndex = group.Min(p => p.Time), MaxIndex = group.Max(p => p.Time) })
.ToList();
结果和
string[] listUid = new [] { "abc", "def" };
// Then in the Match
.Match(c => c.listUid.Any(i => c.Uid.Contains(i));
甚至:
{ "$match": { "Uid": { "$in": ["abc", "def"] } } }
对于较短且相同的内容使用按ID连接。使用按ID连接。谢谢它很有帮助谢谢它很有帮助