The reason you get null is because you are trying to convert an IQueryable based on an anonymous type to IEnumerable<TimelineItem> ( new { t.Description, t.Title } creates an instance of an anonymous type with two fields - Description and Title ). You must remove the Select part for it to work.
If you want to select only Description and Title , create a named type with these two fields and return an IEnumerable this type:
public class TitleDescr { public string Title {get;set;} public string Description {get;set;} } public IEnumerable<TitleDescr> GetTimeLineItems(int SelectedPID) { return from t in db.TimelineItems where t.ProductID == SelectedPID select new TitleDescr { t.Description, t.Title }; }
dasblinkenlight
source share