我决定将我的项目从 切换.NET6到.NE 8. 我的项目数据库是SQL Server 2016。
起初一切都很顺利,但我遇到了一个错误:
var seferIds = tList.expedition.Select(r => r.Key).ToArray();
var sql = (from h in context.Line
join v in context.Route on h.id equals v.lineId
join s in context.Expedition on v.id equals s.routeId
where seferIds.Contains(s.id)
select new { h, v, s })
.ToDictionary(r => r.s.id);
Run Code Online (Sandbox Code Playgroud)
这样,我就无法Contains()在使用数据库表 ( ) 创建的 Linq 查询中使用AsQueryable。
我做了一些研究,如果我将其定义为
where seferIds.AsQueryable().Contains(s.id)
Run Code Online (Sandbox Code Playgroud)
错误消失。同时,我需要seferIds.Any()在我的代码中以 的形式进行空检查。
我查看了使用 SQL Server 2019 作为数据库是否会遇到相同的错误,并且可以where seferIds.Contains(s.id)正常工作,没有任何问题,也没有错误。
至于我的问题,这个问题是.net8不再兼容旧数据库版本的问题吗?还有其他我错过的情况吗?
我想知道这个错误是否有不同的解决方案。
sql-server entity-framework-core asp.net-core .net-8.0 ef-core-8.0
我面临这个问题,我浏览了几篇帖子,请回复我如何解决这个问题。下面是我的代码
控制器类
在第三行中我收到错误:
实体类型 Employee 不是当前上下文模型的一部分
public ActionResult Details(int id)
{
MvcApplication6.Models.EmployeeContext employeeContext = new MvcApplication6.Models.EmployeeContext();
MvcApplication6.Models.Employee employee = employeeContext.Employees.Single(x => x.Id == id);
return View(employee);
}
Run Code Online (Sandbox Code Playgroud)
EmployeeContext 类
public class EmployeeContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
模型类
namespace MvcApplication6.Models
{
[Table("tblEmployee")]
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; } …Run Code Online (Sandbox Code Playgroud) 我有一个令人兴奋的 NavMenu 组件
<MudPaper Class="py-3" Elevation="0">
<MudNavMenu>
<MudNavLink Href="/" Match="NavLinkMatch.All">Home</MudNavLink>
<MudNavLink Href="/posts" Match="NavLinkMatch.All">Articles</MudNavLink>
<MudNavLink Href="/about" Match="NavLinkMatch.All">About</MudNavLink>
</MudNavMenu>
</MudPaper>
<MudSwitch @ref="@darkModeSwitch" *@ ... @* />
Run Code Online (Sandbox Code Playgroud)
那是在 a 里面MudDrawer。我真正想要的是将所有 NavLink 放在顶部,将开关放在底部,但我尝试过的所有操作似乎都没有效果。看起来该MudDrawer组件是在列表中一个接一个的事物上设置的。我缺少什么?或者有什么快速解决办法吗?
大多数情况下,我尝试在开关周围放置一个容器并为其提供顶部边距,并使用对齐和调整弹性类。
.net-8.0 ×1
asp.net-core ×1
asp.net-mvc ×1
blazor ×1
c# ×1
ef-core-8.0 ×1
mudblazor ×1
sql-server ×1