﻿---
title: ES|QL in the .NET client
description: This page helps you understand and use ES|QL in the .NET client. The recommended way to work with ES|QL is the LINQ to ES|QL provider, which lets you...
url: https://www.elastic.co/elastic/docs-builder/docs/2990/reference/elasticsearch/clients/dotnet/esql
products:
  - Elasticsearch
  - Elasticsearch .NET Client
  - Elasticsearch Client
---

# ES|QL in the .NET client
This page helps you understand and use [ES|QL](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/2990/reference/query-languages/esql) in the .NET client.
The recommended way to work with ES|QL is the [LINQ to ES|QL](https://www.elastic.co/elastic/docs-builder/docs/2990/reference/elasticsearch/clients/dotnet/linq-to-esql) provider, which lets you write type-safe C# LINQ queries that are automatically translated to ES|QL at runtime.
For lower-level control, you can also use the Elasticsearch [ES|QL API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) directly: This is the most flexible approach, but it's also the most complex because you must handle results in their raw form.
You can choose the precise format of results, such as JSON, CSV, or text.

## How to use the ES|QL API

The [ES|QL query API](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-esql) allows you to specify how results should be returned. You can choose a [response format](https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/2990/reference/query-languages/esql/esql-rest#esql-rest-format) such as CSV, text, or JSON, then fine-tune it with parameters like column separators and locale.
The following example gets ES|QL results as CSV and parses them:
```csharp
var response = await client.Esql.QueryAsync(r => r
    .Query("FROM index")
    .Format("csv")
);

var csvContents = Encoding.UTF8.GetString(response.Data);
```


## Consume ES|QL results

The previous example showed that although the raw ES|QL API offers maximum flexibility, additional work is required to use the result data.
The recommended approach is [LINQ to ES|QL](https://www.elastic.co/elastic/docs-builder/docs/2990/reference/elasticsearch/clients/dotnet/linq-to-esql), which provides type-safe queries with automatic result mapping. Refer to the [LINQ to ES|QL](https://www.elastic.co/elastic/docs-builder/docs/2990/reference/elasticsearch/clients/dotnet/linq-to-esql) documentation for details.