Hey there! I am trying to write a POCO class in the correct F # ... But something is wrong.
C # code that I want to translate to the correct F #:
public class MyTest { [Key] public int ID { get; set; } public string Name { get; set; } }
Closest I can go to the above code in F #, for example:
type Mytest() = let mutable _id : int = 0; let mutable _name : string = null; [<KeyAttribute>] member x.ID with public get() : int = _id and public set(value) = _id <- value member x.Name with public get() : string = _name and public set value = _name <- value
However, when I try to access the properties of the F # version, it just returns a compilation error saying
"Search for an object of an indefinite type based on information up to this point in the program. A type annotation may be required before this program item to restrict the type of object. This may allow the search to be allowed.
The code trying to get the property is part of my repository (I use EF code first).
module Databasethings = let GetEntries = let ctx = new SevenContext() let mydbset = ctx.Set<MyTest>() let entries = mydbset.Select(fun item -> item.Name).ToList()
What the hell is going on?
Thanks in advance!
source share