以下方法之间的调用是不明确的System.Linq.Enumerable.ToList()

时间:2017-07-17 19:06:17

标签: c# asp.net linq visual-studio-2017 asp.net-core-1.1

我的asp.net解决方案有一个针对框架 net 4.62 的类库。当我调用.ToList()时,我收到一个错误。

  

以下方法或属性之间的调用不明确:System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)

阅读SO上的类似错误,我可以得出结论,我的文件中有重复的代码。我在对象资源管理器中搜索了程序集,发现它们位于 System.Core [4.0.0.0] System.Core [5.0.5.0]

这是班级:

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;

namespace PortalRepository.Implementation.Repositories
{
    public class PortalRepository<TEntity>: IPortalRepository<TEntity> where TEntity:class 
    {
        internal readonly PORTAL_Entities _context;
        internal IDbSet<TEntity> _dbSet;

        private IDbSet<TEntity> Entities
        {
            set { }
            get { return _dbSet ?? (_dbSet = _context.Set<TEntity>()); }
        }
        public IList<TEntity> AllEntities
        {
            set { }
            get { return Entities.ToList(); //ambiguous call here}
        }
    }
// plus other implementation of Entities and AllEntities
}

我收到来自Visual Studio 2017的警告,“无法解决'System.Core,Version = 4.0.0.0,...'和'System.Core,Version = 3.5.0.0,...之间的冲突。 “我认为上面的错误与此有关,但是挖掘到Object explorer我在System.Core v3.5.0.0中找不到方法System.Linq.Enumerable.ToList()。所以,我'我很困惑。

更新

在这个项目中,依赖关系是:

-Assemblies
    *System
    *System.Core
    *System.Data
    *System.Drawing
    *System.IO.Compression.FileSystem
    *System.Numerics
    *System.Runtime.Serialization
    *System.Xml
    *System.Xml.Linq
    *System.Xml.Serialization
-NuGet
    *EntityFramework(6.1.3)

END UPDATE

自从我继承了一个ASP.NET核心项目并且必须添加.Net 4.62类库以来,让这个项目继续进行是一项挑战。我对C#的了解正在增长,但仍处于起步阶段。非常感谢任何帮助或指导。

0 个答案:

没有答案
相关问题