open Microsoft.FSharp.Reflection let recordHeader<'record> : string [] = FSharpType.GetRecordFields(typeof<'record>) |> Array.map (fun field -> field.Name ) let recordValues<'record> (record:'record) : obj [] = FSharpType.GetRecordFields(record.GetType()) |> Array.map (fun field -> FSharpValue.GetRecordField(record,field) ) type GenericEntityArray = {Values: obj array array; Header: string array} type GenericExtract = Result let toGenericResult<'record> (result: Result<'record[], string>) : GenericExtract = match result with | Error error -> Error error | Ok array -> Ok { Header = recordHeader<'record>; Values = array |> Array.map recordValues; }