Your code is going in the right direction. When using Seq.map
(which is like Select
in LINQ), you need to turn a single element of the original sequence into a single element of the new sequence. So the lambda function just needs to create a single instance of the record.
A record is constructed using { Field1 = value1; Field2 = value2; ... }
so you need:
type RawInspectionData(filename : string) =
let allData = restaurantCsv.Load(filename) // works fine
member this.allInspections =
allData.Data
|> Seq.map(fun rcrd -> {inspectionID = rcrd.InspectionID})
I also changed allData
from a member to a local let
definition (which makes it private field of the class). I suppose that your original code new inspection[{...}]
tried to create a singleton array with the element - to create an array you'd write [| { Field = value; ... } |]
(and the compiler would infer the type of the array for you). But in this case, no arrays are needed.