Seq.map from one list to populate another list of another type?

This question is related to an earlier question. Preserving field names at the F # / C # border

Due to the current restriction encountered with providers of type F # (see the previous question), I want to match the list created by the type provider in my own list of entries in which this entry is partially

type inspection = {
    inspectionID : string;
    inspectorID : int;
    EstablishmentID : string;
    EstablishmentName : string;  // other members elided
}

I think a way to do this would be using Seq.map, but I'm not sure. (Recall that I am doing teaching.) So, here is what I tried:

type restaurantCsv = CsvProvider<"C:\somepath\RestaurantRatings2013.csv",HasHeaders=true> 
// which generates a type, but it is an "erased" type, so member names do not propogate
//    over to C#.

type RawInspectionData(filename : string) = 
    member this.allData = restaurantCsv.Load(filename)  // works fine

    member this.allInspections = 
        this.allData.Data
            |> Seq.map(fun rcrd -> new inspection[{inspectionID = rcrd.InspectionID;}])

, , , . - p 43 F # For Scientists, . " " {' . ', ','] ' . "

, , , , . ?

+2
1

. Seq.map ( Select LINQ) . , .

{ Field1 = value1; Field2 = value2; ... }, :

type RawInspectionData(filename : string) = 
  let allData = restaurantCsv.Load(filename)  // works fine
  member this.allInspections = 
    allData.Data
    |> Seq.map(fun rcrd -> {inspectionID = rcrd.InspectionID}) 

allData let ( ). , new inspection[{...}] singleton - , [| { Field = value; ... } |] ( ). .

+3

All Articles