Skip to content

Table queries: Add a simple way to read from Azure Table Storage #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmohl opened this issue Dec 11, 2013 · 0 comments
Open

Table queries: Add a simple way to read from Azure Table Storage #5

dmohl opened this issue Dec 11, 2013 · 0 comments

Comments

@dmohl
Copy link
Owner

dmohl commented Dec 11, 2013

From Tuomas:

The main thing is that the user would like to do table-service-query and not fetch the whole table. But the supported operations are very limited: http://msdn.microsoft.com/en-us/library/windowsazure/dd135725.aspx
I currently use this kind of (non-Fog-)code (of course it would be better to search only by rowkey to not get full table scan, but it is not always possible):

open System
open System.Data
open System.Linq
open Fog.Storage.Table
open System.Configuration
open System.Data.Services.Common
open Microsoft.WindowsAzure.StorageClient

let getItemByCondition partitionKey searchCondition =
let context = BuildTableClient().GetDataServiceContext()
let query =
let beginQuery = query { for item in context.CreateQuery(Azure user table) do
where (item.PartitionKey = partitionKey) }
let filterQuery:IQueryable = searchCondition(beginQuery);
let selectQuery = query { for item in filterQuery do
take 1
select item}
selectQuery
query.AsTableServiceQuery().Execute()
|> Seq.tryFind(fun _ -> true)

let myItem =
let searched = "something"
getItemByCondition "myPartition" (fun iq -> iq.Where(fun (i:MyDataType) -> i.Something = searched))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant