【发布时间】:2017-01-01 15:13:25
【问题描述】:
我有以下 3 个数据表:
Table1
--------------------------------
ScheduleID | Name | Details
-----------------------------
1 S1 schedule details
2 S2 schedule details
3 S3 schedule details
4 S4 schedule details
Table2
------------------------------
ScheduleGroupID | ScheduleID
------------------------------
1 1
1 2
1 3
2 4
Table3
-----------------------------------------------
ScheduleGroupID | Description | ScheduleCount
------------------------------------------------
1 Urgent 3
2 Non-urgent 1
Expected Result
---------------------------------------------------------------
ScheduleID | Name | Details | ScheduleGroupID | Description
-------------------------------------------------------------
1 S1 5 1 Urgent(row from table3)
2 S2 5 1 Urgent(row from table3)
3 S3 5 1 Urgent(row from table3)
4 S4 5 2 Non-urgent(from table3)
所以我有三个数据表,并希望将它们合并到一个表中,以产生如上所示的预期结果。这如何在 c# 中完成?我想我必须使用 LINQ,但没有太多经验。
【问题讨论】:
-
实体框架和 LINQ,你需要一个实体框架模型还是你已经这样做了?您将在表格上获得一个导航属性
-
@MarkHomer,他不需要,有很多方法都不需要,虽然这可能是最简单的
-
@MikeT 你能提供更多关于这些其他方式的信息吗,我正在尝试避免使用实体框架
-
@MikeT 不,他没有,但他为什么不呢?为什么不想使用实体框架?
标签: c# asp.net-mvc datatable dataset