【发布时间】:2010-01-06 07:36:13
【问题描述】:
我有以下两张表(基本大纲):
Tbl_CategoryType
身份证 等级ID 说明
Tbl_Levels ID 名称
基本上,我想在基于 Tbl_CategoryType.LevelID 编号引用 Tbl_Levels.Name 数据时呈现 Tbl_CategoryType 表中的所有信息。
我已尝试在我的存储库中使用如下连接;
public IQueryable GetAllTypesInCategory(int CatID)
{
return (from x in DBEntities.LU_LST_CategoryTypeSet
where x.CategoryID == CatID && x.Enabled == 1
join y in DBEntities.LU_LST_LevelSet on x.LevelID equals y.ID
select new {x, y});
}
但是,当我调用该方法时,没有可以分配给它的类型,因为它不适合 Category 或 Level 的类型。
我假设我需要通过自定义视图模型执行此操作,但无法弄清楚步骤。
提前致谢
【问题讨论】:
标签: asp.net-mvc linq-to-entities viewmodel