Skip to content

Commit

Permalink
Merge remote-tracking branch 'stewart-r/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacabraham committed Jun 14, 2016
2 parents 2033caf + e1b5678 commit beb09ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/FSharp.Azure.StorageTypeProvider/Table/ProvidedTableTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ type AzureTable internal (defaultConnection, tableName) =
let Partition(partitionKey), Row(rowKey) = entityId
DynamicTableEntity(partitionKey, rowKey, ETag = "*"))
|> executeBatchOperation TableOperation.Delete table

/// Deletes an entire partition from the table
member __.DeletePartition(partitionKey, ?connectionString) =
let table = getTableForConnection (defaultArg connectionString defaultConnection)
let filter = Table.TableQuery.GenerateFilterCondition ("PartitionKey", Table.QueryComparisons.Equal, partitionKey)
let projection = [|"RowKey"|]
(new Table.TableQuery<Table.DynamicTableEntity>()).Where(filter).Select(projection)
|> table.ExecuteQuery
|> Seq.map(fun e -> (Partition(e.PartitionKey), Row(e.RowKey)))
|> __.Delete
|> ignore

/// Gets the name of the table.
member __.Name = tableName
Expand Down
8 changes: 7 additions & 1 deletion tests/IntegrationTests/TableUnitTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@ let ``Cloud Table Client relates to the same data as the type provider``() =
(Local.Tables.CloudTableClient.ListTables()
|> Seq.map(fun c -> c.Name)
|> Set.ofSeq
|> Set.contains "employee") =! true
|> Set.contains "employee") =! true

[<Fact>]
[<ResetTableData>]
let ``DeletePartition deletes entries with given partition key``() =
table.DeletePartition "men"
Assert.Equal (0,table.Query().``Where Partition Key Is``.``Equal To``("men").Execute().Length)

0 comments on commit beb09ed

Please sign in to comment.