如果我有一个返回 IQueryable 结果集的页面类,例如:
protected virtual IQueryable<EntityResult> GetEntities(ETBDataContext pContext)
{
return from e in pContext.Entities
where e.SectionId == SectionId && e.StatusCode == "Published"
orderby e.PublishDate descending
select new EntityResult
{
EntityId = e.Id,
Excerpt = e.Excerpt,
Name = e.Name,
PublishDate = e.PublishDate,
ShortDescription = e.ShortDescription
};
}
如果我在继承的类中调用此方法,如何清除选择并获取 ShortDescription?
public void IQueryable<EntityResult> GetResult(ETBDataContext pContext)
{
IQueryable<EntityResult> pQuery = base.GetEntities(pContext);
//right here: how can I just return the ShortDescription Only?
return pQuery;
}
我正在使用默认的 GetEntities() 来执行默认查询的标准选择操作,但在某些调用中,我只想获取我需要的特定数据。
这可能吗?还有其他方法吗?提前致谢!!