【发布时间】:2017-12-05 13:13:32
【问题描述】:
在 APL 方面我是一个完全的新手,我希望你们中的一些优秀的人能够帮助我......
我有一个用 C# 编写并导出到 dll 的类库。然后我在 Dyalog APL (v14.0) 中导入这个类,我能够实例化类库中定义的类型的对象,并且可以根据需要访问字段。但是我发现自己无法遍历任何 List
C# 类(没什么好写的,但我把它包括在内以防万一):
namespace Motor_lib.Objects
{
public class Motor
{
public int? Id_motor = null;
public string Reference = null;
public string Message = null;
public DateTime? Date_modif = null;
public int? Id_hydrotorque = null;
public int? Id_spline = null;
public int? Id_pivot = null;
public int? Id_cam_cover = null;
public int? Id_cam_B_sup = null;
public int? Id_status = null;
public int? Id_CalcType = null;
public Status Status = null;
public Calculation_type Calculation_type = null;
public Spline Spline = null;
public List<Relation> Compatible_Valving_covers;
public Valving_cover Valving_cover = null;
//even more fields...
public Motor()
{
}
//Methods...
}
}
返回 APL:
⎕using ← 'Motor_lib.Objects,D:\Motor_lib.dll'
⍝Fetch a motor from db
myMotor ← Motor.Get 5
⍝The following works
myMotor.Reference
⍝produce the following output
Ref of 5
myMotor.Reference ← ⊂'new ref of 5' ⍝Also works
⍝Now if i do
myMotor.Compatible_Valving_covers.Count
⍝Produces 2 which is correct
myMotor.Compatible_Valving_covers[1].Reference ⍝Also works; I can access the
reference...
我的问题是:如何遍历 List 的每个元素并显示它们的字段值?我尝试了以下方法,但没有成功:
]display ⌷¨myMotor.Compatible_Valving_covers
┌────────────────────────────────────────────────────────────┐
│ ┌→───────────────────────────────────────────────────────┐ │
│ │ Motor_lib.Objects.Relation Motor_lib.Objects.Relation │ │
│ └#───────────────────────────────────────────────────────┘ │
└∊───────────────────────────────────────────────────────────┘
如何让它显示 Relation 字段的值(如 Relation.Id 或 Relation.Reference ...)
抱歉,这个问题很长,如果不清楚。 任何帮助表示赞赏。
【问题讨论】:
-
我不确定我是否完全理解,但请尝试删除
¨,例如:]display ⌷myMotor.Compatible_Valving_covers。 -
你能不能。将
]display ⌷myMotor.Compatible_Valving_covers.Reference的结果添加到您的问题中? (希望这有助于回答...) -
对不起,我的回复晚了,@Adám
code]display ⌷myMotor.Compatible_Valving_covers ┌→───────────────────── ──────────────────────────────┐ │ Motor_lib.Objects.Relation Motor_lib.Objects.Relation │ └#─── ────────────────────────────────────────────────── ──┘ @MBaascode]display ⌷myMotor.Compatible_Valving_covers.Reference * 命令执行失败:VALUE ERROR