I have a method:
public DzieckoAndOpiekunCollection GetChildAndOpiekunByFirstnameLastname(string firstname, string lastname)
{
DataTransfer.ChargeInSchoo
SonarQube reported Return an empty collection instead of null. and I had a problem with the error with casting as in the title of this question.
I was able to get rid of both only using return XYZ.ToList().AsQueryable(); in a method with IQueryable like so:
public IQueryable MethodName (...) {
IQueryable XYZ;
...
return XYZ.ToList().AsQueryable();
}
Hope so it helps for those in a similar scenario(s).