日期:2014-05-20  浏览次数:20884 次

如何返回或序列化匿名类?
public ??? test(){
var select = (from i in db select new {id=db.id,title=db.title}).ToList();
}

现在得到的select 是一个匿名类的List,如何才能返回或者序列化这个list呢?

------解决方案--------------------
List<T> list= (from i in db select new {id=db.id,title=db.title}).ToList(); 
XmlSerializer ser = new XmlSerializer(list.GetType()); 
ser.Serialize(new FileStream(@"a.xml", FileMode.Create), list);