0

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.

Do you guys know a simple way to compare and get all the movies from all the users's compagnies?

Thanks a lot!

1 Answer 1

2

try this:

var toReturn = await _filmCollection.Find(item => item.CompagnyOwner == compagny.CompagnyName.Contains(item.CompagnyOwner)).ToListAsync();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.