<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Fsharp on aklefdal&#39;s tech blog</title>
    <link>https://aklefdal.com/tags/fsharp/</link>
    <description>Recent content in Fsharp on aklefdal&#39;s tech blog</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 29 Dec 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://aklefdal.com/tags/fsharp/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Query Azure Table Storage using F#</title>
      <link>https://aklefdal.com/2024/12/query-azure-table-storage-using-f/</link>
      <pubDate>Sun, 29 Dec 2024 00:00:00 +0000</pubDate>
      <guid>https://aklefdal.com/2024/12/query-azure-table-storage-using-f/</guid>
      <description>&lt;p&gt;When looking at the signature of the &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableclient.queryasync?view=azure-dotnet&#34;&gt;TableClient.QueryAsync&lt;/a&gt; method in Azure.Data.Tables SDK, it is not clear how to use it. It returns a &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/azure.asyncpageable-1?view=azure-dotnet&#34;&gt;&lt;code&gt;AsyncPageable&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/a&gt;. Fortunately that again implements the &lt;a href=&#34;https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1?view=net-9.0&#34;&gt;&lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;&lt;/a&gt;, which means that we can use the Fsharp.Control.TaskSeq library to get the resulting entities.&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Install &lt;a href=&#34;https://www.nuget.org/packages/FSharp.Control.TaskSeq&#34;&gt;FSharp.Control.TaskSeq&lt;/a&gt; NuGet-package to your project.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;code&gt;open FSharp.Control&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Write your code using the &lt;code&gt;TaskSeq&lt;/code&gt; module&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-f#&#34; data-lang=&#34;f#&#34;&gt;let getPartitionRows (tableClient: TableClient) (partition: string) =&#xA;    task {&#xA;        return!&#xA;            tableClient.QueryAsync&amp;lt;TableEntity&amp;gt;(filter = $&amp;#34;PartitionKey eq &amp;#39;{partition}&amp;#39;&amp;#34;)&#xA;            |&amp;gt; TaskSeq.map fromEntity&#xA;            |&amp;gt; TaskSeq.toArrayAsync&#xA;    }&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is written as a reminder to myself, so that I can easily find it again&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
