From 0269944b7ee12ee9fb236c096f3c10bb4ffcb685 Mon Sep 17 00:00:00 2001 From: A Date: Sun, 1 May 2022 02:24:47 +0300 Subject: [PATCH] Add XML docs and other minor fixes --- RqliteDotnet/RqliteClient.cs | 30 +++++++++++++++++++++++++++--- RqliteDotnet/RqliteDotnet.nuspec | 2 +- RqliteDotnet/RqliteOrmClient.cs | 6 +++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/RqliteDotnet/RqliteClient.cs b/RqliteDotnet/RqliteClient.cs index 31c0664..1b0d4c3 100644 --- a/RqliteDotnet/RqliteClient.cs +++ b/RqliteDotnet/RqliteClient.cs @@ -14,14 +14,22 @@ public RqliteClient(string uri, HttpClient? client = null) { _httpClient = client ?? new HttpClient(){ BaseAddress = new Uri(uri) }; } - + + /// + /// Ping Rqlite instance + /// + /// String containining Rqlite version public async Task Ping() { var x = await _httpClient.GetAsync("/status"); return x.Headers.GetValues("X-Rqlite-Version").FirstOrDefault()!; } - + + /// + /// Query DB and return result + /// + /// public async Task Query(string query) { var data = "&q="+Uri.EscapeDataString(query); @@ -33,7 +41,10 @@ public async Task Query(string query) var result = JsonSerializer.Deserialize(str, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); return result; } - + + /// + /// Execute command and return result + /// public async Task Execute(string command) { var request = new HttpRequestMessage(HttpMethod.Post, "/db/execute?timings"); @@ -43,6 +54,12 @@ public async Task Execute(string command) return result; } + /// + /// Execute one or several commands and return result + /// + /// Commands to execute + /// Command flags, e.g. whether to use transaction + /// public async Task Execute(IEnumerable commands, DbFlag? flags) { var parameters = GetParameters(flags); @@ -55,6 +72,13 @@ public async Task Execute(IEnumerable commands, DbFlag? return result; } + /// + /// Query DB using parametrized statement + /// + /// + /// + /// + /// public async Task QueryParams(string query, params T[] qps) where T: QueryParameter { var request = new HttpRequestMessage(HttpMethod.Post, "/db/query?timings"); diff --git a/RqliteDotnet/RqliteDotnet.nuspec b/RqliteDotnet/RqliteDotnet.nuspec index ae7cc74..3f10702 100644 --- a/RqliteDotnet/RqliteDotnet.nuspec +++ b/RqliteDotnet/RqliteDotnet.nuspec @@ -2,7 +2,7 @@ RqliteDotnet - 1.0.1 + 1.0.2 arthrp, otoolep et al. Client for Rqlite - lightweight distributed database en-US diff --git a/RqliteDotnet/RqliteOrmClient.cs b/RqliteDotnet/RqliteOrmClient.cs index aa10b50..3b06781 100644 --- a/RqliteDotnet/RqliteOrmClient.cs +++ b/RqliteDotnet/RqliteOrmClient.cs @@ -7,7 +7,7 @@ public class RqliteOrmClient : RqliteClient public RqliteOrmClient(string uri, HttpClient? client = null) : base(uri, client) {} /// - /// Query Rqlite and return result as an instance of T + /// Query Rqlite DB and return result as an instance of T /// /// Query to execute /// Type of result object @@ -30,9 +30,9 @@ public RqliteOrmClient(string uri, HttpClient? client = null) : base(uri, client foreach (var prop in typeof(T).GetProperties()) { var index = res.Columns.FindIndex(c => c.ToLower() == prop.Name.ToLower()); - var x = GetValue(res.Types[index], res.Values[i][index]); + var val = GetValue(res.Types[index], res.Values[i][index]); - prop.SetValue(dto, x); + prop.SetValue(dto, val); } list.Add(dto);