-
Notifications
You must be signed in to change notification settings - Fork 5
Description
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))