我的 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}
}
} …Run Code Online (Sandbox Code Playgroud)