# C# / .NET fluent query

**URL:** <https://discuss.elastic.co/t/c-net-fluent-query/51842>\
**Category:** Elasticsearch\
**Created:** [June 4, 2016, 2:44am UTC](https://discuss.elastic.co/t/c-net-fluent-query/51842 "2016-06-04T02:44:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasD3](https://avatars.discourse-cdn.com/v4/letter/t/eb9ed0/32.png) [@ThomasD3](https://discuss.elastic.co/u/ThomasD3)\
**Post date:** [June 4, 2016, 2:44am UTC](https://discuss.elastic.co/t/c-net-fluent-query/51842/1 "2016-06-04T02:44:52Z")

</div>

Let's assume the following:

> var Match = EC.Search(\_ =\> \_  
> .Query(Q =\> Q.Term(P =\> P.Category, (int)Category)  
> .Query(Q =\> Q.Term(P =\> P.Type, (int)Type));

Does this mean Query1 AND Query2, or Query 1 OR Query2?

Now if I do create a conditional query:

> var Match = EC.Search(\_ =\> \_  
> .Query(Q =\>  
> {  
> if (a \> b) return Q.Term(P =\> P.Mine, true);  
> else return null;  
> }  
> Query(Q =\> Q.Term(P =\> P.Category, (int)Category)  
> .Query(Q =\> Q.Term(P =\> P.Type, (int)Type));

If I do this, does returning null allow to completely ignore this query? I just want to add this piece IF the condition a \> b is true

And, last, if I use some operators:

> var Match = EC.Search(\_ =\> \_  
> .Query(Q =\>  
> Q.Term(P =\> P.Category, (int)Category)  
> && Q.Term(P =\> P.Type, (int)Type));

How can I use a lambda expression in the query?

> var Match = EC.Search(\_ =\> \_  
> .Query(Q =\>  
> { .... }  
> && Q.Term(P =\> P.Category, (int)Category)  
> && Q.Term(P =\> P.Type, (int)Type));

will not compile....

---

<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:** [July 5, 2017, 10:46pm UTC](https://discuss.elastic.co/t/c-net-fluent-query/51842/2 "2017-07-05T22:46:16Z")

</div>


