diff --git a/Directory.Build.props b/Directory.Build.props
index 42c24ea..c1ba296 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,14 +5,14 @@
Cabazure
Cabazure
- Library for creating .NET Clients for your AspNetCore REST APIs, using Source Generators directed by attributes.
+ Library for handling and executing Kusto scripts against an Azure Data Explorer cluster.
en
en-US
true
embedded
true
git
- https://github.com/Cabazure/Cabazure.Client
+ https://github.com/Cabazure/Cabazure.Kusto
diff --git a/README.md b/README.md
index 94986b3..3034660 100644
--- a/README.md
+++ b/README.md
@@ -106,3 +106,7 @@ app.MapGet(
The `maxItemCount` specifies how many items to return for each page. Each page is returned with a `continuationToken` that can be specified to fetch the next page.
The optional `sessionId` can be provided to optimize the use of storage on the ADX. If the same `sessionId` is specified for two calls they will share the underlying storage for pagination results.
+
+## Sample
+
+Please see the [SampleApi project](https://github.com/Cabazure/Cabazure.Kusto/tree/main/samples/SampleApi), for an example of how Cabazure.Kusto can be setup to query the "ContosoSales" database of the ADX sample cluster.
diff --git a/samples/SampleApi/Contracts/Customer.cs b/samples/SampleApi/Contracts/Customer.cs
index ae92ba2..577c215 100644
--- a/samples/SampleApi/Contracts/Customer.cs
+++ b/samples/SampleApi/Contracts/Customer.cs
@@ -1,5 +1,15 @@
namespace SampleApi.Contracts;
public record Customer(
- string CustomerKey,
- string CustomerName);
+ int CustomerKey,
+ string FirstName,
+ string LastName,
+ string? CompanyName,
+ string CityName,
+ string StateProvinceName,
+ string RegionCountryName,
+ string ContinentName,
+ string Gender,
+ string MaritalStatus,
+ string Education,
+ string Occupation);
\ No newline at end of file
diff --git a/samples/SampleApi/Program.cs b/samples/SampleApi/Program.cs
index e778e08..8892683 100644
--- a/samples/SampleApi/Program.cs
+++ b/samples/SampleApi/Program.cs
@@ -1,5 +1,6 @@
using Azure.Identity;
using Cabazure.Kusto;
+using Microsoft.AspNetCore.Mvc;
using SampleApi.Queries;
var builder = WebApplication.CreateBuilder(args);
@@ -24,9 +25,38 @@
app.UseHttpsRedirection();
-app.MapGet("/customers", (IKustoProcessor processor, CancellationToken cancellationToken)
- => processor.ExecuteAsync(new CustomersQuery(), cancellationToken))
- .WithName("GetCustomers")
+app.MapGet(
+ "/customers",
+ async static (
+ [FromHeader(Name = "x-client-session-id")] string? sessionId,
+ [FromHeader(Name = "x-max-item-count")] int? maxItemCount,
+ [FromHeader(Name = "x-continuation-token")] string? continuationToken,
+ IKustoProcessor processor,
+ CancellationToken cancellationToken)
+ => await processor.ExecuteAsync(
+ new CustomersQuery(),
+ sessionId,
+ maxItemCount ?? 100,
+ continuationToken,
+ cancellationToken))
+ .WithName("ListCustomers")
+ .WithOpenApi();
+
+app.MapGet(
+ "/customers/{customerId}",
+ async static (
+ int customerId,
+ IKustoProcessor processor,
+ CancellationToken cancellationToken)
+ => await processor.ExecuteAsync(
+ new CustomersQuery(
+ customerId),
+ cancellationToken) switch
+ {
+ [{ } customer] => Results.Ok(customer),
+ _ => Results.NotFound(),
+ })
+ .WithName("GetCustomer")
.WithOpenApi();
app.MapGet("/customer-sales", (IKustoProcessor processor, CancellationToken cancellationToken)
diff --git a/samples/SampleApi/Queries/CustomersQuery.cs b/samples/SampleApi/Queries/CustomersQuery.cs
index a770a2b..a0f5ce0 100644
--- a/samples/SampleApi/Queries/CustomersQuery.cs
+++ b/samples/SampleApi/Queries/CustomersQuery.cs
@@ -3,4 +3,6 @@
namespace SampleApi.Queries;
-public record CustomersQuery : KustoQuery;
+public record CustomersQuery(
+ int? CustomerId = null)
+ : KustoQuery;
diff --git a/samples/SampleApi/Queries/CustomersQuery.kusto b/samples/SampleApi/Queries/CustomersQuery.kusto
index 486bf66..d7b62ec 100644
--- a/samples/SampleApi/Queries/CustomersQuery.kusto
+++ b/samples/SampleApi/Queries/CustomersQuery.kusto
@@ -1,4 +1,18 @@
-Customers
+declare query_parameters (
+ customerId:long = long(null)
+);
+Customers
+| where isnull(customerId) or customerId == CustomerKey
| project
CustomerKey,
- CustomerName = strcat(FirstName, ' ', LastName)
+ FirstName,
+ LastName,
+ CompanyName,
+ CityName,
+ StateProvinceName,
+ RegionCountryName,
+ ContinentName,
+ Gender,
+ MaritalStatus,
+ Education,
+ Occupation
\ No newline at end of file