Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
356 stars 62 forks source link

Convert DuckDBResult to class to benefit from reference semantics. #29

Closed kmosegaard closed 2 years ago

kmosegaard commented 2 years ago

This pull request converts DuckDBResult to a class instead of a struct. This is to avoid copying DuckDBResult at some steps. This could alternatively be done by adding ref to all the methods taking a DuckDBResult.

This changes the interface for the methods that "returns" a DuckDBResult from:

var queryResult = new DuckDBResult();
result = DuckDBQuery(connection, "CREATE TABLE integers(foo INTEGER, bar INTEGER);", out queryResult);

or alternatively:

result = DuckDBQuery(connection, "CREATE TABLE integers(foo INTEGER, bar INTEGER);", out var queryResult);

to:

var queryResult = new DuckDBResult();
result = DuckDBQuery(connection, "CREATE TABLE integers(foo INTEGER, bar INTEGER);", queryResult);

This change will also enable passing null instead of an instance of DuckDBResult.

Giorgi commented 2 years ago

@kmosegaard Is converting to class the best choice in this case?