[英]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.