Skip to content

Commit 9d88a08

Browse files
committed
Implements #147 - Supports Rpc specifying a generic type for its return.
1 parent b1071ac commit 9d88a08

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Postgrest/Client.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ public IPostgrestTableWithCache<T> Table<T>(IPostgrestCacheProvider cacheProvide
104104
};
105105

106106

107+
/// <inheritdoc />
108+
public async Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters = null)
109+
{
110+
var response = await Rpc(procedureName, parameters);
111+
112+
return string.IsNullOrEmpty(response.Content) ? default : JsonConvert.DeserializeObject<TModeledResponse>(response.Content!);
113+
}
114+
107115
/// <inheritdoc />
108116
public Task<BaseResponse> Rpc(string procedureName, object? parameters = null)
109117
{

Postgrest/Interfaces/IPostgrestClient.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ public interface IPostgrestClient : IGettableHeaders
6262
/// <returns></returns>
6363
Task<BaseResponse> Rpc(string procedureName, object? parameters);
6464

65+
/// <summary>
66+
/// Perform a stored procedure call.
67+
/// </summary>
68+
/// <param name="procedureName">The function name to call</param>
69+
/// <param name="parameters">The parameters to pass to the function call</param>
70+
/// <typeparam name="TModeledResponse">A type used for hydrating the HTTP response content (hydration through JSON.NET)</typeparam>
71+
/// <returns>A hydrated model</returns>
72+
Task<TModeledResponse?> Rpc<TModeledResponse>(string procedureName, object? parameters = null);
73+
6574
/// <summary>
6675
/// Returns a Table Query Builder instance for a defined model - representative of `USE $TABLE`
6776
/// </summary>

0 commit comments

Comments
 (0)