输入'System.Linq.Enumerable + WhereSelectListIterator`2 [[Services.Client.DomainValueMEMBERFIELDS,Services.Client,Version = 12.2.4.0,Culture = neutral,PublicKeyToken = null],[System.String,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]]'在Assembly'System.Core,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'未标记为可序列化。
有没有人有想法序列化上述内容?
答案 0 :(得分:0)
听起来你要么试图在会话中存储一个匿名类型:
var somethingInTheSession = aCollection
.Where(x => ??)
.Select(x => x.Id, x.Name);
这不可序列化,因为anonymous types can't be serialised as XML
或者,如果要在Select方法中创建已知类型,则必须先调用ToList才能序列化:
var somethingInTheSession = aCollection
.Where(x => ??)
.Select(x => new Person { Id = x.Id, Name = x.Name)
.ToList();
否则序列化程序必须序列化尚未枚举的IEnumerable
,这就是它失败的原因。