fixer-m / snowflake-db-net-client

Snowflake .NET Client
Apache License 2.0
51 stars 14 forks source link

Feature request: ExecuteScalar<T> and ExecuteScalarAsync<T> #32

Closed tsanton closed 1 year ago

tsanton commented 1 year ago

Hi,

First of all; great client! I'm wondering if you would consider altering the ExecuteScalars to accept a generic of type string, int, double, bool etc..? Typical usages will be select count(1) and the like^^

Will make the code look cleaner if we could remove the type casting.

Wouldn't mind having a crack at it if you're pressed for time.

Speak soon!

/T

fixer-m commented 1 year ago

@Tsanton Hi! Thanks, that's a nice improvement. This is implemented now in 0.4.4. Commit: https://github.com/fixer-m/snowflake-db-net-client/commit/ebac54f2100a108aec9f50354e0c4f61f75351a4

fixer-m commented 1 year ago

So there is a new public API method ExecuteScalarAsync which can be used like this:

var result = await _snowflakeClient.ExecuteScalarAsync<int>("SELECT 1;");
Assert.AreEqual(1, result);

Don't forget to specify correct C# type according to Snowflake value type.

Closing this.