尝试在ASP.net MVC实体框架中执行.Distinct()子句,但在以下代码中收到错误:
var tblGlobalLogOnLogOffStudentBans = db.tblGlobalLogOnLogOffStudentBans.Include(t => t.tblGlobalLogOnLogOffTime).OrderBy(t => t.StartBan).Take(10).Select(t => t.UserID).Distinct();
Run Code Online (Sandbox Code Playgroud)
错误是:
异常详细信息:System.InvalidOperationException:传递到字典中的模型项的类型为'System.Collections.Generic.List`1 [System.Nullable .1 [System.Int32]]',但此字典需要类型的模型项'System.Collections.Generic.IEnumerable`1 [Dashboard.tblGlobalLogOnLogOffStudentBan]'.
t => t.UserID是一个Int,但在页面上显示为用户名+名字和姓氏.有任何想法吗?
谢谢克里斯
我们有一个非常烦人的问题,大约一个月前开始,我们可以在一个需要自动代码生成/脚手架的MVC项目中添加一个控制器.
我们今天发现它与平台有关.最初,它设置为任何CPU,对我来说似乎是正确的设置.但是,我们将其设置为x86,因为我们的Visual Studio版本是32位,我们可以再次添加控制器.添加了一个构建的控制器,然后去查看应用程序,它会出现以下错误:
无法加载文件或程序集"仪表板"或其依赖项之一.尝试加载格式不正确的程序.描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.BadImageFormatException:无法加载文件或程序集"仪表板"或其依赖项之一.尝试加载格式不正确的程序.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Dashboard' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There …Run Code Online (Sandbox Code Playgroud)