简体   繁体   English

通用列表在.net核心中不包含AsQueryable()

[英]Generic list doesn't contains AsQueryable() in .net core

I'm writing my class library and after commit changes to git, application stop working - build ends with really strange error: 我正在编写我的类库,并在对git进行更改之后,应用程序停止工作-构建以非常奇怪的错误结束:

'IList' does not contain a definition for 'AsQueryable' and no extension method 'AsQueryable' accepting a first argument of type 'IList' could be found (are you missing a using directive or an assembly reference?) “ IList”不包含“ AsQueryable”的定义,找不到可以接受类型为“ IList”的第一个参数的扩展方法“ AsQueryable”(您是否缺少using指令或程序集引用?)

using System.Collections.Generic;
using System.Linq;

using Idea7.Entity;
using Idea7.Query;

namespace Idea7.Repository
{
    /// <summary>
    /// Abstract in-memory repository
    /// </summary>
    public abstract class InMemoryRepository<TEntity, TKey> : IRepository<TEntity, TKey>
        where TEntity : class, IEntity<TKey>
    {
        public abstract IList<TEntity> Data { get; }

        public long Count(IQueryObject<TEntity> query)
        {
            return query.Count(Data.AsQueryable());
        }

        public IEnumerable<TEntity> Fetch(IQueryObject<TEntity> query)
        {
            return query.Fetch(Data.AsQueryable());
        }

        public TEntity FetchOne(IQueryObject<TEntity> query)
        {
            return query.FetchOne(Data.AsQueryable());
        }

        public TEntity Find(TKey id)
        {
            return Data.SingleOrDefault(s => s.Id.Equals(id));
        }

        public void Create(TEntity entity)
        {
            Data.Add(entity);
        }

        public void Update(TEntity entity)
        {
            Delete(entity);
            Create(entity);
        }

        public void Delete(TEntity entity)
        {
            Data.Remove(entity);
        }
    }
}

What am I missing? 我想念什么?

Here is project.json 这是project.json

{
  "version": "1.0.0-*",
  "description": "Idea7.Repository Class Library",
  "authors": [ "Sebastian Bušek" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "frameworks": {
    "dnx451": { },
    "dnx50": { },
    "netcore50": { }
  },

  "dependencies": {
    "Idea7.Entity": "1.0.0-*",
    "Idea7.Query": "1.0.0-*",
    "Idea7.UnitOfWork": "1.0.0-*",
    "Microsoft.CSharp": "4.0.1-beta-23516"
  }
}

您是否在project.json引用中添加了此代码?

"System.Linq.Queryable": "4.0.1-beta-23516"

AsQuerable是System.Linq程序集/命名空间的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .Contains() in.Where() EF Core 不起作用 .NET Core 3.1.8 - .Contains() in .Where() EF Core doesn't work .NET Core 3.1.8 覆盖.NET通用列表 <MyType> 。载有(MyTypeInstance)? - Override .NET Generic List<MyType>.Contains(MyTypeInstance)? .net 核心 6 - 实体框架 - 何时使用 AsEnumerable AsQueryable - .net core 6 - Entity Framework - when to use AsEnumerable AsQueryable 为什么不能查询 <T> 暗示对_t鉴别符进行过滤 - Why doesn't AsQueryable<T> imply a filter on the _t discriminator NET Core 6.0:可以创建通用方法来获取列表<t>来自 EF 核心?</t> - NET Core 6.0 : Is possible to create generic methods to get a List<T> from EF Core? 联接与AsQueryable上的任何结果都不匹配 <T> ()集合 - Join doesn't match any result on AsQueryable<T>() collection C# Core Get Generic Class T of Generic List<t></t> - C# Core Get Generic Class T of Generic List<T> 如何在 NET Core 中使用通用列表对通用 Class 进行 CRUD? - How to CRUD a Generic Class with Generic List in NET Core? ASP.NET 核心 - MVC - 当 Model 包含列表时回发<t>与派生类</t> - ASP.NET Core - MVC - Post back when Model contains List<T> with Derived classes C# List.AsQueryable() 返回 System.Collections.Generic.List 而不是 IQueryable - C# List.AsQueryable() returns System.Collections.Generic.List instead of IQueryable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM