# ElasticsearchClient v.8 QueryContainer alternative

**URL:** https://discuss.elastic.co/t/elasticsearchclient-v-8-querycontainer-alternative/345861
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [October 26, 2023, 6:32pm UTC](https://discuss.elastic.co/t/elasticsearchclient-v-8-querycontainer-alternative/345861 "2023-10-26T18:32:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Carlos\_Barros](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_barros/32/66891_2.png) [@Carlos\_Barros](https://discuss.elastic.co/u/Carlos_Barros)
#### Post date: [October 26, 2023, 6:32pm UTC](https://discuss.elastic.co/t/elasticsearchclient-v-8-querycontainer-alternative/345861/1 "2023-10-26T18:32:16Z")

</div>

Hi, I'm migrating .net 7 Nest client to the newer v8 .net client.

I have the following code and would like to question if there is an alternative to QueryContainer usage as you see next.

```auto
            QueryContainer filterPerfilUsuario;
            
            if (!isServidor)
            {
                filterPerfilUsuario = new QueryContainer(
                        new TermsQuery
                        {
                            Field = new Field("Nivel"),
                            Terms = (new[] { nivel0, nivel1 })
                        }
                    );
            }
            else
            {
                filterPerfilUsuario = new QueryContainer(
                    new MatchQuery
                    {
                        Field = new Field("Nivel"),
                        Query = nivel1
                    } && new TermsQuery
                    {
                        Field = new Field("IdUnidade"),
                        Terms = uas
                    }
                );
            }

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 23, 2023, 6:32pm UTC](https://discuss.elastic.co/t/elasticsearchclient-v-8-querycontainer-alternative/345861/2 "2023-11-23T18:32:42Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
