LINQ 把IQueryable<T>转换为List<List<string>> 本帖最后由 yuemb369 于 2011-07-21 17:24:04 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //以下代码 测试通过void Main(){var list=new List<User>{ new User{ userID=1, userName="u1"}, new User{ userID=2, userName="u2"}, new User{ userID=3, userName="u3"},};PropertyInfo[] _properties = typeof(User).GetProperties();var result = list.Select(value => _properties.Select (prop => (prop.GetValue(value, new object[0]) ?? string.Empty).ToString()) .ToList()).ToList(); }public class User{ public int userID{get;set;} public string userName{get;set;}} IQueryable<User> queriable = (.....).ToList(); //数据从库中取出来后 加载到存中先 很对,很强大,原来缺了个ToList() 求教OPC高手【远程连接问题】 数据库操作 求助求助 ,c#如何调用一个c++写的控件啊?!~~ 按记录数量多少为记录排序,然后再从大到小取出记录的算法 在C#中,如何将Excel中的数据导入到Sql数据库中,谢谢,在线等!!! 求教 登陆条件解析 C#怎么收取并保存邮件 很变态的问题,如何将指定的汉字转成拼音? 求简单通讯源码 如何获得本机DNS地址 多表查询的问题 C# 如何把类名当做类本身来用?
//以下代码 测试通过
void Main()
{
var list=new List<User>{
new User{ userID=1, userName="u1"},
new User{ userID=2, userName="u2"},
new User{ userID=3, userName="u3"},
};
PropertyInfo[] _properties = typeof(User).GetProperties();var result = list.Select(value => _properties.Select (prop => (prop.GetValue(value, new object[0]) ?? string.Empty).ToString()) .ToList()).ToList();
}
public class User
{
public int userID{get;set;}
public string userName{get;set;}
}