Saving field names at the F # / C # border

As a training exercise, I am doing data analysis in a csv file with 5000 lines using the functionality of F # and F # type-provider. When I use the generated type-type type in f #, naturally, the header lines of the csv file become the names of the type fields.

type restaurantCsv = CsvProvider<"C:\Users\Paul\Desktop\HealthDepartment\RestaurantRatings2013.csv",HasHeaders=true>

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

    member public this.inspectionsList = this.allData.Data.ToList()

    member this.FilterByName(name : string) =
        this.allData.Data 
            |> Seq.filter (fun x -> x.EstablishmentName.Contains(name))

In addition, I call the F # code (in the library that the code creates above) from the C # file test block. It is working fine. But when I use the IEnumberable returned by F # from FilterByName, the field name information is not saved. So I have code that displays the new field names in .Item1, Item2, etc. From Tuple:

var inspectionsOnCafes = inspections2013.FilterByName("Cafe");
var inspections = (from row in inspectionsOnCafes
                    select new
                    {
                       inspectorID = row.Item3,
                       restaurantName = row.Item5,
                       inspectionDate = row.Rest.Item6
                    }).ToList();

# F #, row.Item # easy-to-read ? , , :

inspectorID = row.InspectorID,
// etc.

. F #, #?, , , . , , .

+4
1

F # . . .

#, :

  • - . , , API. . . #, # .

  • - . , , #.

, , , . , , . F # #, .

+2

All Articles