Reputation: 117
i'm a actually struggling with mongoDb collection and asp.net core.
previously, i made an async function to getall the movies owned by the user's compagny, but i wanted to change that for the user to be able to be in mutliple differents compagnies.
Compagny compagny contains a public string[] compagnyNames;
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);
}
I can't find a way to checks all the movies from all compagnies, here i can only get the movies owned by compagnyName[0] and not all of them.
Do you guys know a simple way to pass through all the strings contained in Compagny compagny?
I'm a junior so maybe i'm not very clear.
Feel free to ask precisions.
thanks!
Upvotes: 0
Views: 60
Reputation: 874
try this:
var toReturn = await _filmCollection.Find(item => compagny.CompagnyName.Contains(item.CompagnyOwner)).ToListAsync();
Upvotes: 2