How to correctly map POCO objects to InsertBinaryAsync ClickHouse

1 week ago 12
ARTICLE AD BOX

I am using the ClickHouse.Driver library in my .NET project to insert data into ClickHouse. I have a POCO class and I want to use the InsertBinaryAsync method for high-performance inserts.

I'm wondering how I should correctly enter the columns and values?
For example

public class CourierRow { public Guid Id { get; init; } public string Name { get; init; } = string.Empty; public decimal Price { get; init; } public DateTime RandomTime { get; init; } } public class MyClickHouseService(IClickHouseClient clickHouseClient) : IMyClickHouseService { public async Task Add(CourierRow courierRow) { clickHouseClient.InsertBinaryAsync( "couriers", ) } }

I don't feel like doing it this way:

var columns = new[]{ "id", "name", "price", "random_time" }; var row = new object[] { orders.Id, orders.Name, orders.Price, orders.RandomTime }; await clickHouseClient.InsertBinaryAsync("couriers", columns, [row]);

Are there any solutions for automatically mapping an object without constant reflection?

Read Entire Article