我已经搜索过,但我可能错过了正确的帖子。这是我的问题。
public class Post
{
public int Id { get; set; }
public int Subject { get; set; }
public int Text { get; set; }
public DateTime Date { get; set; }
}
string[] columnsNeeded = {"Subject", "Text"};
var list = _service.GetAllPosts();
var filteredList = list.Select(..)
//list = [{Subject="1", Text="1"}, {Subject="2", Text="2"},{Subject="3", Text="3"}...]
columnsNeeded
变量是动态的,从外部定义我需要的列。如何获取上面的过滤列表?