1

您好,我在控制器类中有这个 lambda 表达式,我只想取模

return PartialView( db.AcessosUsuarios               
           .Join(db.Perfils,
           Au => Au.IdPerfil,
           p => p.IdMenu,
           (Au, p) => new { AcessosUsuarios = Au, Perfils = p })
           .Where(x => x.AcessosUsuarios.IdUsuario == Usu)
           .Join(db.Menus,
           p => p.Perfils.IdPerfil,
           Me => Me.IdMenu,
           (Me, p) => new { Menus = Me, Perfils = p })
           .Join(db.Modulos,
           Me => Me.Menus.Perfils.IdMenu,
           Mo => Mo.IdModulo,
           (Me, Mo) => new { Modulos = Mo, Menus = Me, Me.Menus.Perfils.IdMenu })
           .OrderByDescending(Mod => Mod.Modulos.Ordem)
           .Join(db.AcessosAssinantes,
           Mo => Mo.Modulos.IdModulo,
           Aa => Aa.IdModulo,
           (Mo, Aa) => new { Modulos = Mo, AcessosAssinantes = Aa })
           .Where(y => y.AcessosAssinantes.IdAssinante == Ass)
           .Select(s => new { s.Modulos.Modulos})
           .ToList().AsEnumerable());

风景

@model IEnumerable<Models.Modulos>

错误是:

传入字典的模型项的类型为“System.Collections.Generic.List 1[<>f__AnonymousType61[Models.Modulos]]”,但此字典需要类型为“System.Collections.Generic.IEnumerable`1[Models.Modulos”的模型项]'

任何人都可以帮助我吗??谢谢

4

1 回答 1

2

看起来您已经用这一行不必要地创建了一个匿名类型:

.Select(s => new { s.Modulos.Modulos})

简单地尝试(应该返回一个IEnumerable<Modulos>):

.Select(s => s.Modulos.Modulos)
于 2013-07-03T23:33:49.347 回答