私は AppFabric キャッシュを試していますが、取得したデータをキャッシュに保存する際に問題が発生しました。問題の根本は、AppFabric キャッシュでは、データに DataContract 属性と Datamember 属性を保存するクラスに適用する必要があるように思われることです。
その場合、これを保存するにはどうすればよいですか (簡略化されたコード):
var q = (from u in dbContext.Users
select new
{
Name = u.Name,
Id = u.RowId
});
cache.Put(“test”, q.ToList());
Put を呼び出すと、次の例外が発生します。
System.Runtime.Serialization.InvalidDataContractException was caught
Message=Type '<>f__AnonymousTypec`6[System.Int32,System.String,System.Nullable`1[System.Int32],System.Boolean,System.Nullable`1[System.Int32],System.Int32]' cannot
be serialized. Consider marking it with the DataContractAttribute attribute, and
marking all of its members you want serialized with the DataMemberAttribute
attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework
documentation for other supported types.
AppFabric がキャッシュできるように IQueryable の結果をシリアル化するにはどうすればよいですか?
ありがとうございました、
リック