如何添加过滤器以便我只返回RelationshipTypeIDs 26-30?
public IEnumerable<SelectListOptions> GetRelationshipTypes()
{
return (from q in unitOfWork.GenericRepository<tlkpRelationshipType>().Get()
select new SelectListOptions
{
Value = q.RelationshipTypeID.ToString(),
Label = q.RelationshipType
}
).ToList();
}
答案 0 :(得分:3)
使用where
子句,如下所示:
public IEnumerable<SelectListOptions> GetRelationshipTypes()
{
return (from q in unitOfWork.GenericRepository<tlkpRelationshipType>().Get()
where q.RelationshipTypeID >= 26 && q.RelationshipTypeID <= 30
select new SelectListOptions
{
Value = q.RelationshipTypeID.ToString(),
Label = q.RelationshipType
}
).ToList();
}
答案 1 :(得分:1)
return (from q in unitOfWork.GenericRepository<tlkpRelationshipType>().Get()
where q.RelationshipTypeID >= 26
where q.RelationshipTypeID <= 30
select new SelectListOptions