[英]compare a string array in mongodb collection.find()
I've the following code:我有以下代码:
public class Compagny
{
[BsonElement("compagnyName")]
public string[] CompagnyName { get; set; }
}
public async Task<ActionResult<IEnumerable<Film>>> GetAllFilms([FromBody] Compagny compagny)
{
var toReturn = await _filmCollection.Find(item => item.CompagnyOwner == compagny.CompagnyName[0]).ToListAsync();
return Ok(toReturn);
}
A user can be registered in multiple compagnies but with "compagny.CompagnyName[0]" i'm only able to get all the movies from the [index]'s compagny.一个用户可以在多个公司中注册,但使用“compagny.CompagnyName[0]”我只能从 [index] 的公司中获取所有电影。
Do you guys know a simple way to compare and get all the movies from all the users's compagnies?你们知道一种简单的方法来比较和获取所有用户公司的所有电影吗?
Thanks a lot!非常感谢!
try this:尝试这个:
var toReturn = await _filmCollection.Find(item => item.CompagnyOwner == compagny.CompagnyName.Contains(item.CompagnyOwner)).ToListAsync();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.