# Sort on Elastic Search .NET API

**URL:** <https://discuss.elastic.co/t/sort-on-elastic-search-net-api/365527>\
**Category:** Elasticsearch\
**Created:** [August 26, 2024, 6:43am UTC](https://discuss.elastic.co/t/sort-on-elastic-search-net-api/365527 "2024-08-26T06:43:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![irajeshr](https://avatars.discourse-cdn.com/v4/letter/i/53a042/32.png) [@irajeshr](https://discuss.elastic.co/u/irajeshr)\
**Post date:** [August 26, 2024, 6:43am UTC](https://discuss.elastic.co/t/sort-on-elastic-search-net-api/365527/1 "2024-08-26T06:43:47Z")

</div>

can anyone pls share object initializer syntax for sort requests instead of lambdas?

i tried couple of things but they are not working

**Code:**

```auto
Dim req = New SearchRequest(Of testIndex)(txtIndex2.Text.Trim) With {
     .Query = New TermQuery("user") With {.Value = txtUserName.Text.Trim},
     .Sort = New List(Of ISort) From {
         New FieldSort With {
         .Field = "startedOn",
         .Order = SortOrder.Ascending
     }
 }

```

**Error:**

| Severity | Code | Description | Project | File | Line | Suppression State |
| --- | --- | --- | --- | --- | --- | --- |
| Error (active) | BC30002 | Type 'ISort' is not defined. | ES.aspx.vb | 41 | | |

| Severity | Code | Description | Project | File | Line | Suppression State |
| --- | --- | --- | --- | --- | --- | --- |
| Error (active) | BC30456 | 'Field' is not a member of 'FieldSort'. | ES.aspx.vb | 43 | | |

| Severity | Code | Description | Project | File | Line | Suppression State |
| --- | --- | --- | --- | --- | --- | --- |
| Error (active) | BC30456 | 'Ascending' is not a member of 'SortOrder'. | ES.aspx.vb | 44 | | |
