【发布时间】:2013-11-09 14:10:59
【问题描述】:
我有一个方法用于从我的表中获取选定行的名为 ItemNumber、ItemDescription、UnitDescription 的 3 列的值。我已经传递了该选定行的参数 ItemId,并且必须获取不同变量中的每一列值.我不知道该怎么做。谁能告诉我怎么做。这是我的代码-
public System.Collections.IEnumerable FetchDataItem(int id)
{
var row = (from t1 in context.InventoryUnit
join t2 in context.InventoryItem on t1.UnitId equals t2.UnitId
where t2.ItemId == id
orderby t2.ItemNumber, t2.ItemDescription
select new
{
t2.ItemNumber,
t2.ItemDescription,
t1.UnitDescription
});
return row.ToList();
}
【问题讨论】:
-
确保在
IEnumerable<T>中将返回类型设置为IEnumerable<YourClass>
标签: c# linq entity-framework ienumerable