I'm trying to cast a List to my custom list which is ProjectList
IList<Project> projects = cm.GetOrAdd("projectList", () => (ProjectList)ProjectService.GetAllProjects().ToList(), new CacheItemPolicy(5));
ProjectList contains only:
public class ProjectList : List<Project>
{
public override string ToString()
{
return string.Format("Projects: {0}", this.Count());
}
}
However it's giving a runtime error that it cant cast the object.
Error:
System.Collections.Generic.List`1[sidc.Framework.Data.Entities.Project] can't be converted to type sidc.Framework.Web.Helpers.ProjectList.
Am I overseeing something? I'm using the lambda because my cm (CacheManager) will evaluate the Func<>
when the object is not in cache.