我需要连接两个数据表并从两个表中选择所有值,因为d1列是动态的我已尝试使用下面的代码并获取连接值但是当我选择它时显示在2个DataRows中它应该在一个行
DataTable dtRtn = new DataTable();
var result = from d1 in dtFormData.AsEnumerable()
join d2 in dtResponderDetails.AsEnumerable()
on d1.Field<string>("ResponderId") equals d2.Field<string>("EmployeeId")
select new { d1,d2};
我需要将d1和d2连接结果复制到dtRtn表
修改
我搜索过但没有直接的答案,所有答案都显示了如何选择特定列
请帮助谢谢
答案 0 :(得分:-1)
您需要先将if orbiting_body == "Ariel":
primary_body_radius = 578.9
gravitational_parameter = 90.099
elif orbiting_body == "Callisto":
primary_body_radius = 2410.3
gravitational_parameter = 7181.224
elif orbiting_body == "Ceres":
primary_body_radius = 481.5
gravitational_parameter = 62.66886
elif orbiting_body == "Charon":
primary_body_radius = 603.5
gravitational_parameter = 101.4448
elif orbiting_body == "Deimos":
primary_body_radius = 6.2
gravitational_parameter = 0.000098521588
elif orbiting_body == "Dione":
primary_body_radius = 561.4
gravitational_parameter = 73.14704
elif orbiting_body == "Earth":
primary_body_radius = 6371
gravitational_parameter = 398678.064
elif orbiting_body == "Eris":
primary_body_radius = 1163
gravitational_parameter = 1114.558
elif orbiting_body == "Europa":
primary_body_radius = 1560.8
gravitational_parameter = 3203.52
else:
primary_body_radius = 0.0
gravitational_parameter = 0.0
和dtFormData
中的列动态添加到dtResponderDetails
。然后,您可以遍历LINQ查询的结果,并为每个查询创建新的dtRtn
对象。
以下是您需要添加到当前所需内容的必要代码:
DataRow