These extension methods add additional functionality to your GlobalState instances.
Add or update members of the default database in one step.
Remove members of the default database.
GlobalState.ReplaceDatabaseMembers<TMember>(params (TMember original, TMember replacement)[] replacements)
Replace members of the default database with updated members.
This is similar to updating members with AddOrUpdateDatabaseMembers, but also works when the member names have changed.
Add or update a database within the default cluster.
Add or update multiple databases within the default cluster.
You may want to evaluate a query or command in the context of another command having already been executed, such as a table or function being created or altered, but without actually executing the command on the server and refetching the changed schema.
Instead of having to manually construct the appropriate symbols corresponding to each change you can now just apply the command text directly to the global state and get a new instance with the related schema symbols changed.
var globals = ...;
var result = globals.ApplyCommand(".create table Customers (Id: long, Name: string)");
if (result.Succeeded)
{
var code = KustoCode.ParseAndAnalyze("Customers | where Name == 'Matt'", globals: result.Globals);
}
else
{
ReportErrors(result.Errors);
}To apply more than one command at a time, in order, use GlobalState.ApplyCommands. The changes caused by each command will be visible in each subsequent command.
var result = _globals.ApplyCommands(
".create table T (x: long, y: string)",
".create function F() { T };"
);
var globals = result.Globals;Or use a single execute script command.
var result = _globals.ApplyCommands(
"""
.execute script <|
.create table T(x: long, y: string);
.create function F() { T };
"""
);
var globals = result.Globals;