CSharp.OpenSource.LinqToKql 1.3.1

dotnet add package CSharp.OpenSource.LinqToKql --version 1.3.1
                    
NuGet\Install-Package CSharp.OpenSource.LinqToKql -Version 1.3.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CSharp.OpenSource.LinqToKql" Version="1.3.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSharp.OpenSource.LinqToKql" Version="1.3.1" />
                    
Directory.Packages.props
<PackageReference Include="CSharp.OpenSource.LinqToKql" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CSharp.OpenSource.LinqToKql --version 1.3.1
                    
#r "nuget: CSharp.OpenSource.LinqToKql, 1.3.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CSharp.OpenSource.LinqToKql@1.3.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CSharp.OpenSource.LinqToKql&version=1.3.1
                    
Install as a Cake Addin
#tool nuget:?package=CSharp.OpenSource.LinqToKql&version=1.3.1
                    
Install as a Cake Tool

CSharp.OpenSource.LinqToKql

Nuget Package NuGet Version

Example of using ORMGenerator

Live Example

Generate

var providerExecutor = _mockExecutor.Object;
var ormGenerator = new ORMGenerator(new()
{
    ProviderExecutor = providerExecutor,
    ModelsFolderPath = "../../../../ORMGeneratorTests/Models",
    DbContextFolderPath = "../../../../ORMGeneratorTests",
    DbContextName = "AutoGenORMKustoDbContext",
    Namespace = "AutoGen",
    ModelsNamespace = "AutoGen",
    DbContextNamespace = "AutoGen",
    CreateDbContext = true,
    CleanFolderBeforeCreate = true,
    EnableNullable = true,
    FileScopedNamespaces = true,
    DatabaseConfigs = new List<ORMGeneratorDatabaseConfig>
    {
        new ORMGeneratorDatabaseConfig
        {
            DatabaseName = DbName1,
            Filters = new ORMGeneratorFilterConfig()
        },
        new ORMGeneratorDatabaseConfig
        {
            DatabaseName = DbName2,
            DatabaseDisplayName = "db2",
            Filters = new ORMGeneratorFilterConfig()
        }
    }
});
await _ormGenerator.GenerateAsync();
// output example https://github.com/csharp-opensource/CSharp.OpenSource.LinqToKql/tree/master/Samples/ORMGeneratorTest

Usage

using AutoGen;
using CSharp.OpenSource.LinqToKql.Extensions;
using CSharp.OpenSource.LinqToKql.Http;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();
services.AddKustoDbContext<AutoGenORMKustoDbContext, KustoHttpClient>(sp => new KustoHttpClient("mycluster", "auth", "dbName"));
var provider = services.BuildServiceProvider();
var dbContext = provider.GetRequiredService<AutoGenORMKustoDbContext>();

dbContext.TestTable1.Where(x => x.TestColumn == "test").ToList();
dbContext.db2<object>("customQuery").ToList();
dbContext.func1().ToList();
dbContext.func2("name", "lastName").ToList();

Example of using KustoDbContext

public interface IMyMultiDbContext : IKustoDbContext
{
    IQueryable<SampleObject> SampleObjects { get; }
    IQueryable<SampleObject2> SampleObjects2 { get; }

    IQueryable<SampleObject> Func(int minYear);
    IQueryable<SampleObject> Func2(int minYear);
    IQueryable<SampleObject> Func3(int minYear);
}

public class MyMultiDbContext : KustoDbContext, IMyMultiDbContext
{
    public MyMultiDbContext(IKustoDbContextExecutor<MyMultiDbContext> executor) : base(executor)
    {
    }

    // from default db
    public IQueryable<SampleObject> SampleObjects
        => CreateQuery<SampleObject>("sampleObjects");

    // from different db
    public IQueryable<SampleObject2> SampleObjects2
        => CreateQuery<SampleObject2>("sampleObjects2", database: "diffDb");

    public IQueryable<SampleObject> Func(int minYear)
        => CreateQuery<SampleObject>($"sampleObjects | where year > {minYear}");

    public IQueryable<SampleObject> Func2(int minYear)
        => CreateQuery<SampleObject>($"sampleObjectsByMinYear({minYear})");

    public IQueryable<SampleObject> Func3(int minYear)
        => SampleObjects.Where(x => x.Year > minYear);

    protected override LinqToKQLQueryTranslatorConfig GetConfig() => new() { DisableNestedProjection = true };
}

Example of using KustoHttpClientLinqProviderFactory

using CSharp.OpenSource.LinqToKql.Http;
using CSharp.OpenSource.LinqToKql.Test.Model;

namespace CSharp.OpenSource.LinqToKql.Test.Provider;

public class SampleKustoHttpClientLinqProviderFactory : KustoHttpClientLinqProviderFactory
{
    private string _cluster = "https://myclusterUrl/";
    private string _auth = "myBearerToken";
    private string _defaultDbName = "myDatabaseName";

    public IQueryable<SampleObject> SampleObject
        => CreateQuery<SampleObject>(_cluster, _auth, _defaultDbName, "SampleObjectTable");

    public IQueryable<SampleObject> SampleObjectFunction(long number)
        => CreateQuery<SampleObject>(_cluster, _auth, _defaultDbName, $"SampleObjectFunction({number})");

    public IQueryable<SampleObject2> SampleObject2(long number)
        => CreateQuery<SampleObject2>(_cluster, _auth, _defaultDbName, $"SampleObject2Table");
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1 2,188 1/27/2025
1.3.0 248 1/22/2025
1.2.9 144 1/22/2025
1.2.8 131 1/22/2025
1.2.7 219 1/21/2025
1.2.6 246 1/6/2025
1.2.5 165 1/6/2025
1.2.4 326 12/19/2024
1.2.3 155 12/19/2024
1.2.2 147 12/18/2024
1.2.1 153 12/18/2024
1.2.0 153 12/17/2024
1.1.9 149 12/17/2024
1.1.8 136 12/17/2024
1.1.7 150 12/17/2024
1.1.6 157 12/17/2024
1.1.5 138 12/17/2024
1.1.4 165 12/14/2024
1.1.3 150 12/14/2024
1.1.2 402 12/8/2024
1.1.1 147 12/8/2024
1.1.0 149 12/8/2024
1.0.37 145 12/8/2024
1.0.35 153 12/5/2024
1.0.34 231 12/2/2024
1.0.33 135 12/2/2024
1.0.32 147 12/2/2024
1.0.31 148 12/2/2024
1.0.30 138 12/2/2024
1.0.29 159 12/2/2024
1.0.28 164 12/1/2024
1.0.25 151 12/1/2024
1.0.24 156 11/29/2024
1.0.23 135 11/29/2024
1.0.22 224 11/27/2024
1.0.21 148 11/27/2024
1.0.20 147 11/27/2024
1.0.19 186 11/27/2024
1.0.18 149 11/26/2024
1.0.17 164 11/24/2024
1.0.16 153 11/24/2024
1.0.15 155 11/18/2024
1.0.14 142 11/18/2024
1.0.13 133 11/18/2024
1.0.12 180 11/18/2024
1.0.11 151 11/18/2024
1.0.10 143 11/18/2024
1.0.9 127 11/18/2024
1.0.8 144 11/17/2024
1.0.7 153 11/17/2024
1.0.6 144 11/17/2024
1.0.5 136 11/17/2024
1.0.4 146 11/17/2024
1.0.3 136 11/17/2024
1.0.2 145 11/17/2024
1.0.1 141 11/17/2024
1.0.0 144 11/17/2024
0.0.1 135 11/17/2024