This might be a really stupid and obvious question, but I’m very new to Linq. In my Data Access Layer class I have this method:
static public ? GetAllUrls()
{
using (MonitoredUrlsEntities mu = new MonitoredUrlsEntities())
{
var query = from urlTbl in mu.UrlLists
join histTbl in mu.Histories on
urlTbl.ID equals histTbl.UrlID
select new
{
urlTbl.Url,
urlTbl.UrlTitle,
urlTbl.UrlType,
urlTbl.Frequency,
urlTbl.Active,
urlTbl.LastChangeDate,
urlTbl.LastCheckDate,
histTbl.DateRun,
histTbl.HashValue
};
return query.ToList();
}
The question mark is there because I have no idea what type of object a linq statement returns. I just a list that I can loop through.
Can’t return anonymous types from a method (like others have said). Create a concrete type and new one of those up. Your return type is
IEnumerable<YourType>as below: