My asp.net solution has a class library that targets framework net 4.62. I'm getting an error when I call .ToList().
The call is ambiguous between the following methods or properties:
System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)andSystem.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)
Reading through similar errors on SO, I can conclude that I have duplicate code in my files. I searched through the assembly in Object Explorer and found that they are located in both System.Core[4.0.0.0] and System.Core[5.0.5.0].
Here's the class:
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
}
I am getting warnings from Visual Studio 2017 that there is "No way to resolve conflict between 'System.Core, Version=4.0.0.0,...' and 'System.Core, Version=3.5.0.0,...' I thought that the above error would be related to this, but digging into Object explorer I couldn't find the method System.Linq.Enumerable.ToList() in the System.Core v3.5.0.0. So, I'm confused.
UPDATE
In this project the Dependencies are:
-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
It has been a challenge to get this project up and going since I inherited an ASP.NET Core project and had to add .Net 4.62 class libraries to it. My knowledge of C# is growing, but is still in its infancy. Any help or guidance is much appreciated.