CML*_*Lee 5 c# linq asp.net 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
}
Run Code Online (Sandbox Code Playgroud)
我收到来自 Visual Studio 2017 的警告“无法解决‘System.Core, Version=4.0.0.0,...’和‘System.Core, Version=3.5.0.0,...’之间的冲突”我认为上述错误与此有关,但深入研究对象资源管理器,我在 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)
Run Code Online (Sandbox Code Playgroud)
结束更新
自从我继承了一个 ASP.NET Core 项目并且不得不向其中添加 .Net 4.62 类库以来,启动和运行这个项目一直是一个挑战。我对 C# 的了解在不断增长,但仍处于起步阶段。非常感谢任何帮助或指导。
| 归档时间: |
|
| 查看次数: |
3408 次 |
| 最近记录: |