I have this Elastic query:

```
"aggs":{
  "GroupByDomeinRelatieCode":{
     "aggs":{
        "SumNettoRegelBedrag":{
           "sum":{
                    "script": {
                      "lang": "painless",
                      "source": "doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100 "
                    } 
                 }
        }
     },
     "terms":{
        "field":"domeinRelatieCode.keyword",
        "size":10000
     }
  },
  "TotalSumAggragation":{
     "sum":{
                "script": {
                  "lang": "painless",
                  "source": "doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100 "
                } 
             }
  }
}

```

And I need to convert it to C# Nest with object initializer.
My current code:

```
var aggs = new AggregationDictionary()
{
    { "GroupByDomeinRelatieCode" ,   new TermsAggregation("GroupByDomeinRelatieCode")
        {
            Field = Infer.Field<ElasticInvoiceLine>(x => x.DomeinRelatieCode.Suffix("keyword")),
            Size = 10000,
            Aggregations = new SumAggregation("SumNettoRegelBedrag", ADD SCRIPT HERE?)
        }
    },
    { "TotalSumAggragation", new SumAggregation("TotalSumAggragation", ADD SCRIPT HERE?)}
};

```

I have tried to use ScriptQuery and ScriptField but the SumAggregation won't accept it.

```
var script = new ScriptQuery
{
    Name = "UitgesteldeKorting",
    Script = new InlineScript("doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100")
    {
        Lang = "painless"
    },
};

var scriptField = new ScriptField()
{
    Script = new InlineScript("doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100")
    {
        Lang = "painless"
    }
};

```

I don't know how to add the script part to the SumAggregations. How can I do this?
Thx!
['https://Stackoverflow.com/questions/61823205', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/731127/']
You can pass the script via `Script` property, like this 

```
Aggregations = new SumAggregation("SumNettoRegelBedrag", null) { Script = new InlineScript("") }

```

Hope that helps.
Can you try this one? 

```
{
  "aggs": {
    "GroupByDomeinRelatieCode": {
      "aggs": {
        "SumNettoRegelBedrag": {
          "sum": {
            "script": "doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100 "
          }
        }
      },
      "terms": {
        "field": "domeinRelatieCode.keyword",
        "size": 10000
      }
    },
    "TotalSumAggragation": {
      "sum": {
        "script": "doc['nettoRegelbedrag'].value * (100 - doc['uitgesteldeKortingsPercentage'].value) / 100 "
      }
    }
  }
}

```