C# 以下方法System.Linq.Enumerable.ToList()之间的调用不明确
我的asp.net解决方案有一个类库,目标是frameworknet 4.62。调用.ToList()时出错 以下方法或属性之间的调用不明确:C# 以下方法System.Linq.Enumerable.ToList()之间的调用不明确,c#,asp.net,linq,visual-studio-2017,asp.net-core-1.1,C#,Asp.net,Linq,Visual Studio 2017,Asp.net Core 1.1,我的asp.net解决方案有一个类库,目标是frameworknet 4.62。调用.ToList()时出错 以下方法或属性之间的调用不明确:System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable)和System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable) 通过阅读类似的错误,我可以得出结论,我的文件中有重复的代码。我在Object
System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable)
和System.Linq.Enumerable.ToList(System.Collections.Generic.IEnumerable)
通过阅读类似的错误,我可以得出结论,我的文件中有重复的代码。我在Object Explorer中搜索了程序集,发现它们位于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
}
结束更新
自从我继承了一个ASP.NET核心项目并不得不向其中添加.NET 4.62类库以来,启动和运行这个项目一直是一个挑战。我对C#的了解正在增长,但仍处于初级阶段。非常感谢任何帮助或指导。尝试调用静态方法,而不是使用扩展格式。@casey我尝试使用
返回System.Linq.Enumerable.ToList(Entities)
,但我得到一个错误,即类型Enumerable在v4.0.0和v3.5.0.0的System.Core中都可用。有什么想法吗?听起来你想在一个项目中同时使用.Net核心和.Net框架——我认为这是行不通的。您必须使用/reference/target一个或另一个。@NetMage当我最初尝试以两个框架为目标时,我已经删除了.netCore引用。在csproj文件中,我有net462
。我想知道是否有剩余的核心,如果是的话,我如何删除它。什么是在您的解决方案浏览器的参考部分?
-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)