我有两个表,一个是供用户选择,另一个是来自另一个系统。系统表映射到用户输入表。
Orderables表:
+-----+-------------------------------+
| Key | Orderable |
+-----+-------------------------------+
| 88 | XRAY Spine Cervical |
| 91 | XRAY Spine Lumbar |
| 95 | XRAY Spine Thoracic |
+-----+-------------------------------+
Karisma(系统)表:
+---------------------------+-------------+---------------+
| KarismaName | KarismaCode | OrderableKeys |
+---------------------------+-------------+---------------+
| Spine Cervical | 310XR | 88 |
| Spine Cervical + Lumbar | 302XR | 88|91 |
| Spine Cervical + Thoracic | 301XR | 88|95 |
| Spine Lumbosacral | 330XR | 91 |
| Spine Thoracic | 320XR | 95 |
| Spine Thoracic + Lumbar | 303XR | 95|91 |
+---------------------------+-------------+---------------+
我有这些课程:
public class orderable
{
public int Key { set; get; }
public string Name { set; get; }
public string Modality { set; get; }
public orderable()
{
Key = 0;
Name = string.Empty;
}
}
public class Exam
{
public string KarismaName { set; get; }
public string KarismaCode { set; get; }
public string OrderableKeys { set; get; }
public int Key { set; get; }
public List<orderable> Orderables { set; get; }
public Exam()
{
KarismaCode = string.Empty;
KarismaName = string.Empty;
Key = 0;
Orderables = new List<orderable>();
OrderableKeys = string.Empty;
}
}
public class ConflictExams
{
public List<Exam> ExamList { set; get; }
public List<int> OrderablesList { set; get; }
}
public class ConflictOptions
{
public List<Options> OptionsList { set; get; }
}
public class Options
{
public List<Exam> ExamsList {set; get;}
}
这是我获得所有冲突考试的代码,即出现在多个组合考试中的Orderables:
List<ConflictExams> conflictList = new List<ConflictExams>();
foreach (var i in duplicateKeys)
{
List<Exam> examsList = new List<Exam>();
List<int> orderableList = new List<int>();
foreach (var ex in comboExamsList)
{
var split = ex.OrderableKeys.Split('|');
foreach (var s in split)
{
if(int.Parse(s) == i)
{
examsList.Add(ex);
orderableList.Add(i);
}
}
}
ConflictExams ce = new ConflictExams();
ce.ExamList = examsList;
ce.OrderablesList = orderableList;
conflictList.Add(ce);
}
我的代码的结果是conflictList =
conflictList[0].ExamList[0] = Spine Cervical + Lumbar
conflictList[0].ExamList[1] = Spine Cervical + Thoracic
conflictList[1].ExamList[0] = Spine Cervical + Lumbar
conflictList[1].ExamList[1] = Spine Thoracic + Lumbar
conflictList[2].ExamList[0] = Spine Cervical + Thoracic
conflictList[2].ExamList[1] = Spine Thoracic + Lumbar
我不知道如何从那里获得选项列表,以便用户选择他们想要选择的内容,这是最终目标:
conflictOptionsList[0].Options[0].ExamsList[0] = Spine Cervical + Lumbar
conflictOptionsList[0].Options[0].ExamsList[1] = Spine Thoracic
conflictOptionsList[0].Options[1].ExamsList[0] = Spine Cervical + Thoracic
conflictOptionsList[0].Options[1].ExamsList[1] = Spine Lumbar
conflictOptionsList[0].Options[2].ExamsList[0] = Spine Thoracic + Lumbar
conflictOptionsList[0].Options[2].ExamsList[1] = Spine Cervical
我希望这更有意义,我感谢大家的观察和评论。