-1
  public IList<TagWithCount> GetTagList()
        {
        var query=(from c in this.Query() where c.coupons.Where(d => d.isPublish == true).Count() > 2 select new TagWithCount { tag = c, count = c.coupons.Count }).ToList().OrderBy(x => Guid.NewGuid()).Skip(0).Take(75).ToList();
        return query;
    }

这是我正在调用的方法..

  var a = context.tagService.GetTagList().Distinct(c => c.tag.name.Trim()).ToList() ;
return View(a.Take(20));

我想返回 20 个标签,但不超过 20 个字或少于 4 个

4

1 回答 1

2

我相信这就是你想要的......虽然不太确定......你的问题很模糊......

context.tagService.GetTagList().Where(x => x.tag.name.Length < 20 
                                   && x.tag.name.Length>4)
                               .Take(20).ToList();
于 2012-06-21T07:04:30.757 回答