I migrated an WebAPI from FullDotnet (4.6) to .Net Core 2.0 and I'm having this issue in my Data Layer using Dapper.
My code:
public List<Doctor> GetList()
{
List<Doctor> ret;
using (var db = GetMySqlConnection())
{
const string sql = @"SELECT D.Id, D.Bio, D.CRMState, D.CRMNumber,
U.Id, U.Email, U.CreatedOn, U.LastLogon, U.Login, U.Name, U.Phone, U.Surname, U.Id, U.Birth, U.CPF,
S.Id, S.Name
from Doctor D
inner join User U on U.Id = D.UserId
inner join Speciality S on S.Id = D.IDEspeciality
order by D.Id DESC";
ret = db.Query<Doctor, User, Speciality, Doctor>(sql, (doctor, user, speciality) =>
{
doctor.User = user;
doctor.Speciality = speciality;
return doctor;
}
, splitOn: "Id, Id", commandType: CommandType.Text).ToList();
}
return ret;
}
Strange Behavior:
The solution Builds and WORK The "error" who VisualStudio highlight is:
Argument type 'lambda expression' is not assignable to parameter type 'System.Func`5'
I have another classes with the same behavior and same error, but, again, the code compile and work, but this "error highlight" is annoying!
This highlight I don't have in my old solution running .NET Framework 4.6
Usefull info:
So as we figured it out in the comments, the issue was caused by ReSharper (2017.2).
Some additional steps you can take when suspecting that ReSharper is acting up.
Suspend/resume ReSharper
Just to confirm that ReSharper is causing issues, you can suspend it using:
Tools/Options.../Resharper node/Suspend now
In this case doing a suspend/resume cycle was enough and solved the issue.
Clearing ReSharper cache (source)
Broken caches affect ReSharper behavior. For example, ReSharper can stop resolving symbols or some navigation commands can be unavailable. If you notice such strange behavior, clearing caches for the current solution could help in most cases.
To clear caches for the current solution
- Open the solution with supposedly broken caches in Visual Studio.
- Open the Environment | General page of ReSharper options.
- Click Clear caches. Note that the caches will be only cleaned in the currently selected cache location.
- Reopen your solution for the changes to take effect.
ReSharper also cleans up solution caches automatically if a specific solution was not open for more than 30 days.
What if the above doesn't work?
If you confirmed that it's a ReSharper issue, then you should first try and update to the latest version of ReSharper and try to reproduce your problem.
If the issue still persists, then you should head to the JetBrains bug tracker and file an issue after confirming that it's not an already reported bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With