C#, Visual Studio 2010, LINQ Join Multiple Datatable
本文关键字:Join Multiple Datatable LINQ 2010 Visual Studio | 更新日期: 2023-09-27 18:04:19
我有一个相当大的问题,我似乎无法理解。从一开始……我有三个数据库表:现在我把它们拉到c#程序中的datatable中。这些dt被称为存货和项目。
|-----------------| |------------------|
| - Inventory - | | - Items - |
|-----------------| |------------------|
| slot1 | | itemid |
| qty1 | | itemname |
| slot2 | | item description |
| qty2 | |------------------|
|-----------------|
inventory - slot1中的包含一个物品id。在库存-数量1中包含数量。
条目应该是不言自明的。
在sql中,我确信我会执行一个连接项目,槽1 = "…我的想法吗?
无论如何,我想做的是找出slot 1中物品的itemid,名称和描述。我希望你能理解我的要求……附:我已经在谷歌上搜索过了。大约6个小时,每次我接近我认为会工作的东西,它就是不工作。我很清楚我想做什么,只是不知道该怎么做!另外,我确定它必须是LINQ,因为你不能在c#的数据表上运行sql:/
提前感谢您的帮助。
据我所知,您正在寻找如下内容:
from c in Inventory
from item in Items
where item.ID = c.Slot
select new {c.Slot, item.name, c....}
这是EF的简单启动(我认为比Dataset要好得多,....):http://entityframeworktutorial.net/create-first-simple-EDM.aspx .UUTNmjfxfXw
我选择了教程的一小部分来学习如何制作你的第一个样本,在你看到这个之后,你可以先尝试代码。