小编Pat*_*ick的帖子

Visual Studio 2022 陷入构建困境

我目前使用的是VS2022社区版,并已将其更新到最新版本(17.6.3)。我更新到这个版本是因为每当我在第一次运行后启动控制台应用程序时,构建就停留在“Building”处。这需要我重新启动我的机器才能真正起作用。如果不强制任务管理器停止进程,我什至无法停止构建。

我尝试了以下方法:

  • 删除 bin/obj 文件夹
  • 取消选中项目属性中的代码分析
  • 清洁溶液

我也尝试在 Rider 中打开该产品,但结果是一样的。我怀疑这可能是 MSbuild 问题,但我不知道是什么原因导致的。

控制台应用程序:C#、.net 4.8

visual-studio-2022

8
推荐指数
0
解决办法
2733
查看次数

跳过并无法使用IQueryable数据源

我在服务层中名为“ GetBaseEntity”的所有对象上有一个通用方法。这基本上具有以下定义:

public IQueryable<TEntity> GetBaseEntity(bool includeNavigation = true, bool isAdmin = false)
{
    var objBase = _context.EntityName;

    if (isAdmin)
    {
        return objBase;
    }

    return objBase.Where(x => x.IsActive == true && x.IsDeleted == false);
}
Run Code Online (Sandbox Code Playgroud)

这将返回类型为TEntity的IQueryable。我想在一种方法中动态传递分页选项,因此我以这种方式实现了它:

public async Task<IEnumerable<EntityDto>> LoadResources(PagingOptions pagingOptions)
{
    var baseQuery = GetBaseEntity();

    if (pagingOptions != null)
    {
        baseQuery
            .Skip(pagingOptions.Page.Value * pagingOptions.Limit.Value)
            .Take(pagingOptions.Limit.Value);
    } 

    // I can actually return from this part but I just
    // set it to a variable to see how many rows the query …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core ef-core-2.2

1
推荐指数
1
解决办法
122
查看次数