Skip to main content

Finch.Generators by Ivan Mazurenko

NuGet / site data​

Nuget GitHub last commit GitHub Repo stars

Details​

Info​

info

Name: Finch.Generators

Package Description

Author: Ivan Mazurenko

NuGet: https://www.nuget.org/packages/Finch.Generators/

You can find more details at https://github.com/ivmazurenko/finch

Source: https://github.com/ivmazurenko/finch

Author​

note

Ivan Mazurenko Alt text

Original Readme​

note

Finch - database mapping extension methods source generator

Introduction​

Finch is c# source generator designed to simplify database interactions by generating concise extension methods for database queries mappings.

Getting Started​

  1. Install the Finch NuGet packages:

    $ dotnet add package Finch.Abstractions
    $ dotnet add package Finch.Generators
  2. Mark the required type with an attribute corresponding to your desired database:

    [GenerateSqlserverConnectionExtensions]
    public class TbUser
    {
    public int id \{ get; set; }
    public string name \{ get; set; }
    }
  3. Use the extension method for your type:

    var connection = new SqlConnection(connectionString);
    var items = await connection.QueryAsync<TbUser>("select * from tb_user");

Contribution​

Contributions to Finch are welcome! If you encounter any issues or have ideas for improvement, feel free to open an issue or submit a pull request on GitHub.

License​

Finch is licensed under the MIT License.

About​

note

dapper style generator

How to use​

Example (source csproj, source files)​

This is the CSharp Project that references Finch.Generators

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Finch.Abstractions" Version="0.0.107" />
<PackageReference Include="Finch.Generators" Version="0.0.107" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.1" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
</Project>

Generated Files​

Those are taken from $(BaseIntermediateOutputPath)\GX

// <auto-generated/>

namespace DB;

public static partial class SqlserverConnectionExtensions
{
public static global::System.Collections.Generic.List<T> Query<T>(
this global::Microsoft.Data.SqlClient.SqlConnection connection,
string sql)
where T : new()
{
connection.Open();

var items = new global::System.Collections.Generic.List<T>();
using var command = new global::Microsoft.Data.SqlClient.SqlCommand(sql, connection);
using var reader = command.ExecuteReader();
while (reader.Read())
{
T item = new T();

SqlserverObjectMapper.Map(item, reader);
items.Add(item);
}

return items;
}
}

Useful​

Download Example (.NET C#)​

Share Finch.Generators​

https://ignatandrei.github.io/RSCG_Examples/v2/docs/Finch.Generators

aaa

Category "Database" has the following generators:​

1 AlephMapper Nuget GitHub Repo stars 2026-06-29

2 Breezy Nuget GitHub Repo stars 2023-08-09

3 Dapper.AOT Nuget GitHub Repo stars 2024-12-02

4 Facet.Search Nuget GitHub Repo stars 2025-12-17

5 Finch.Generators Nuget GitHub Repo stars 2025-08-10

6 Gedaq Nuget GitHub Repo stars 2023-07-29

7 TableStorage Nuget GitHub Repo stars 2024-06-01

8 Unflat Nuget GitHub Repo stars 2025-08-18

See category​

Database