type ProcessParametersPair = {Definition:string; Provided:string}
type QueryResult = { DefinitionId:int;DefinitionName:string; ProcessTemplateId:int; StatusName:string; DefinitionArgs:string; BuildArgs:string;
StatusCode:int option;cleanWorkspaceOption:string; RawProcessParameters:ProcessParametersPair; lastBuild:Tbl_Build}
type QueryDisplay = { DefinitionId:int;DefinitionName:string; ProcessTemplateId:int; StatusName:Object; DefinitionArgs:string; BuildArgs:string;
StatusCode:int option;cleanWorkspaceOption:string; RawProcessParameters:Object; lastBuild:Object}
我真的必须重复匹配的QueryDisplayRecord的所有字段吗?我可以像记录实例那样做吗? type QueryDisplay = {QueryResult with lastBuild:Object}
在这种情况下,我根据字段类型改变记录,我也很想知道我是否可以这样做但是在添加的字段而不是类型更改字段。
我不是指实例,我指的是记录类型定义。
这些都可能吗?
答案 0 :(得分:10)
记录类型不能继承"从另一种类型。您可以将所有公共字段放在单独的类型中并引用它:
type Common = { A: int; B: int }
type Record1 = { Common: Common; C: int }
type Record2 = { Common: Common; D: int }
或使用课程:
type Common(a, b) =
member val A = a
member val B = b
type Class1(a, b, c) =
inherit Common(a, b)
member val C = c
type Class2(a, b, d) =
inherit Common(a, b)
member val D = d