Skip to content

Instantly share code, notes, and snippets.

@ThomasPe
Created April 5, 2022 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThomasPe/716dd71c20c408625b01d64263d4160d to your computer and use it in GitHub Desktop.
Save ThomasPe/716dd71c20c408625b01d64263d4160d to your computer and use it in GitHub Desktop.
Get first row from Azure Table Storage
/// <summary>
/// Returns first entity in the table
/// </summary>
/// <typeparam name="T">Implementation of ITableEntity</typeparam>
/// <param name="tableClient">The authenticated TableClient</param>
/// <returns>First entity in table</returns>
public static async Task<T> GetFirstEntityAsync<T>(this TableClient tableClient) where T : class, ITableEntity, new()
{
return await tableClient.QueryAsync<T>(maxPerPage: 1).FirstOrDefaultAsync();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment