Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Asp.Net Core and Returning IEnumerable from Web API

$
0
0

I'm trying to return an IEnumerable and getting error on the "return results statement" as "Error    CS0266    Cannot implicitly convert type 'System.Collections.IEnumerable' to 'System.Collections.Generic.IEnumerable<SP_API.Models.DB.vScheduleDetail>'. An explicit conversion exists (are you missing a cast?)    SP_API..NETCoreApp,Version=v1.0    D:\Scheduler+Plus Web Apps\SP_API\src\SP_API\Repository\vScheduleDetailRepository.cs"
Here is my code.  Note that the commented out line works fine, but I want to have a more detailed selection of data.

public IEnumerable<vScheduleDetail> GetbyScheduleMasterId(int key)
{
   var result = from vScheduleDetail in _context.vScheduleDetail
                select vScheduleDetail;
   result = result.Where(e => e.ScheduleMasterId == key);
   result = result.Where(e => e.Swapped != "1");
   result = result.OrderBy(e => e.Date).ThenBy(e => e.SeqNbr);
   IEnumerable results = result.AsEnumerable();
   return results;
   //return _context.vScheduleDetail.Where(e => e.ScheduleMasterId == key).AsEnumerable();
}

Thanks in advance for assisting with this.
Mark


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>