anchor.diff:  open Raven.Json.Linq
   
   module BatchOperations =
  -    let buildPutCommand (key, doc, etag, _) =
  +    let buildPutCommand (writeRequest:DocumentWriteRequest) =
           let cmd = new PutCommandData()
  -        cmd.Document <- RavenJObject.FromObject(doc)
  -        cmd.Key <- key
  -        cmd.Etag <- etag
  -
  -        let metadata = new Raven.Json.Linq.RavenJObject()
  -        metadata.Add("Raven-Entity-Name", new RavenJValue("MyCountingDocs"))
  -        cmd.Metadata <- metadata
  +        cmd.Document <- writeRequest.Document.Force()
  +        cmd.Key <- writeRequest.DocumentKey
  +        cmd.Etag <- writeRequest.Etag
  +
  +        cmd.Metadata <- writeRequest.Metadata.Force()
           cmd
           
       let writeBatch (documentStore : Raven.Client.IDocumentStore) (docs:seq<BatchWrite>) = async {
           try 
               let! batchResult = 
                   docs
  -                |> Seq.map buildPutCommand
  +                |> Seq.collect (fst >> Seq.map buildPutCommand)
                   |> Seq.cast<ICommandData>
                   |> Array.ofSeq
                   |> documentStore.AsyncDatabaseCommands.BatchAsync
  
positive.code:                 cache.Set(docResult.Key, (doc, docResult.Etag) :> obj, DateTimeOffset.MaxValue) |> ignore
                  do! callback true
          | None ->
              for (docKey, _, _, callback) in docs do
                  cache.Remove(docKey) |> ignore
                  do! callback false
      }
  
negative.code: 
          let result = 
              seq {
                  let doc = new MyCountingDoc()
                  let metadata = new Raven.Json.Linq.RavenJObject()
                  metadata.Add("Raven-Entity-Name", new RavenJValue("MyCountingDocs"))
                  let writeRequests = Seq.singleton {
                      DocumentKey = docKey
                      Document = lazy(RavenJObject.FromObject(doc))
                      Metadata = lazy(metadata)
                      Etag = Raven.Abstractions.Data.Etag.Empty }
                  yield (writeRequests, (fun _ -> async { () }))
              }
              |> BatchOperations.writeBatch documentStore 
              |> Async.RunSynchronously
  