This is my first question here so please go easy on me ;-)
I am taking a course on Udemy to learn ASP.NET MVC 5. This course is being taught using C# but I have been following along using VB.NET. Right about half-way through the course, the instructor introduces a library called AutoMapper for mapping domain objects to DTOs (data transfer objects).
The C# code I am having trouble with:
return _context.Customers.ToList().Select(Mapper.Map<Customer, CustomerDto>);
In VB.NET I believe it should be:
Return _context.Customers.ToList().[Select](Mapper.Map(Of Customer, CustomerDto))
However I am receiving the following errors:
Overload resolution failed because no accessible 'Map' accepts this number of arguments.
Overload resolution failed because no accessible '[Select]' can be called with these arguments: Extension method 'Public Function [Select](Of TResult)(selector As Func(Of Customer, TResult)) As IEnumerable(Of TResult)' defined in 'Enumerable': Type parameter 'TResult' cannot be inferred.
The signature of the AutoMapper function being called:
VB.NET
Public Shared Function Map(Of TSource, TDestination)(source As TSource) As TDestination
C#
public static TDestination Map<TSource, TDestination>(TSource source);
It would appear that while C# allows omitting the (TSource source)
parameter, VB.NET is requiring the same parameter (source As TSource)