fsprojects / FSharp.Azure.Storage

F# API for using Microsoft Azure Table Storage service
MIT License
75 stars 16 forks source link

Type %s must be either an ITableEntity or an F# record type #1

Closed jackfoxy closed 10 years ago

jackfoxy commented 10 years ago

I'm throwing either in Resolver or CreateTableOperation, even with the very generic code from your blog posts. I don't have time to debug right now, but I want to call this to your attention. (I just installed from NuGet about an hour ago.)

type Game =
    { Name : string
      Developer : string
      HasMultiplayer : bool
      Notes : string }
let account = CloudStorageAccount.Parse "UseDevelopmentStorage=true;" //Or your connection string here
let tableClient = account.CreateCloudTableClient()
let inGameTable game = inTable tableClient "Games" game
let game =
        { Name = "Halo 4"
          Developer = "343 Industries"
          HasMultiplayer = true
          Notes = "Finished the game in Legendary difficulty." }

let result = game |> Insert |> inGameTable
daniel-chambers commented 10 years ago

I can't reproduce the exception you're having using that code. I'm testing using the 1.0.0 (stable, not alpha or beta) version of the NuGet package. The exception I get is "The type Game does not contain a property with PartitionKeyAttribute". That's a valid error, because the Game type in your example code is missing the PartitionKey and RowKey attributes off the Game type.

jackfoxy commented 10 years ago

Oh yeah, messed that up when I cut and pasted from the blog post, but after fixing it same problem:

type Game =
    { [<PartitionKey>] Developer : string
      [<RowKey>] Name : string
      HasMultiplayer : bool
      Notes : string }

I'll take closer look when I have time.

daniel-chambers commented 10 years ago

Thanks, that'd be good. :)

jackfoxy commented 10 years ago

The problem was a project file I inherited. I never did diagnose the exact cause, but creating a new project from scratch fixed it. The project was also causing problems with another API library we use. Things built correctly but threw at runtime. Such are the issues when taking over someone else's half-finished project.