【发布时间】:2011-08-22 10:22:17
【问题描述】:
我有两张桌子:
表 product1 与列: product_id 产品名称 类别ID 另一个表类别 类别ID 分类名称 类别描述我正在使用 DataGridView 填充产品详细信息,它工作正常。
我正在尝试根据我获得以下代码的相同条件从同一个表中获取两列值:
string desc = Convert.ToString(selectedRow.Cells["productdescr"].Value);
string productname = Convert.ToString(selectedRow.Cells["productnam"].Value);
string productprices = Convert.ToString(selectedRow.Cells["productprice"].Value);
int productids = Convert.ToInt32(selectedRow.Cells["productid"].Value);
条件 1:
int categoryids = (from cats in tsg.product1
where cats.product_Name.Equals(productname)
select cats.category_Id).SingleOrDefault();
条件 2:
var catogynames = (from categorytypes in tsg.categories
where categorytypes.category_Id.Equals(categoryids)
select categorytypes.category_Name
).SingleOrDefault();
条件 3:
var categoprydecription = (from categorytable in tsg.categories
where categorytable.category_Id.Equals(categoryids)
select categorytable.category_Description
).SingleOrDefault();
我想从 条件 2 中同时获得 categorytypes.category_description 和 categorytypes.category_Name,是否可以将这两个条件结合起来? (条件2和条件3)
【问题讨论】:
标签: c# linq entity-framework linq-to-entities