I am trying to put some distributed caching into play, I'm using this indeXus.Net Shared Cache .
It Requires that the object being cached is serializable, which it is here is the class object.
[Serializable]
public class Members
{
public Members()
{}
public Members(string aspnetusername, string aspnetpassword,
string emailaddr,string location)
: this(0,0,aspnetusername, aspnetpassword,emailaddr,DateTime.Now, location,
0,0,DateTime.Now,DateTime.Now,DateTime.Now,false)
{ }
public Members(Int64? row,int memberid, string aspnetusername, string aspnetpassword,
string emailaddr,DateTime datecreated, string location, int daimokugoal, int previewimageid,
DateTime lastdaimoku, DateTime lastnotifed, DateTime lastactivitydate, bool isactivated)
{
this.Row = row;
this.MemberID = memberid;
this.Aspnetusername = aspnetusername;
this.Aspnetpassword = aspnetpassword;
this.EmailAddr = emailaddr;
this.DateCreated = datecreated;
this.Location = location;
this.DaimokuGoal = daimokugoal;
this.PreviewImageID = previewimageid;
this.LastDaimoku = lastdaimoku;
this.LastNotefied = lastnotifed;
this.LastActivityDate = lastactivitydate;
this.IsActivated = this.IsActivated;
this.Details = new LazyList<MemberDetails>();
this.Blogs = new LazyList<MemberBlogs>();
this.Daimoku = new LazyList<MemberDaimoku>();
this.Determinations = new LazyList<MemberDeterminations>();
this.Encouragements = new LazyList<MemberEncouragements>();
this.Entries = new LazyList<MemberEntries>();
this.Friends = new LazyList<MemberFriends>();
this.Stats = new LazyList<MemberStats>();
}
public Int64? Row { get; set; }
public int MemberID { get; set; }
public string Aspnetusername { get; set; }
public string Aspnetpassword { get; set; }
public string EmailAddr { get; set; }
public DateTime DateCreated { get; set; }
public string Location { get; set; }
public int DaimokuGoal { get; set; }
public int PreviewImageID { get; set; }
public DateTime LastDaimoku { get; set; }
public DateTime LastNotefied { get; set; }
public DateTime LastActivityDate { get; set; }
public bool IsActivated { get; set; }
public LazyList<MemberDetails> Details { get; set; }
public LazyList<MemberBlogs> Blogs { get; set; }
public LazyList<MemberDaimoku> Daimoku { get; set; }
public LazyList<MemberDeterminations> Determinations { get; set; }
public LazyList<MemberEncouragements> Encouragements { get; set; }
public LazyList<MemberEntries> Entries { get; set; }
public LazyList<MemberFriends> Friends { get; set; }
public LazyList<MemberStats> Stats { get; set; }
}
The LINQtoSql is this that populates this class.
public IQueryable<Members> GetMemberInfo()
{
using (var t = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
{
var results = from m in _datacontext.ViewMembers
let details = GetMemberDetails(m.MemberID)
let determinations = GetMemberDeterminations(m.MemberID)
let daimoku = GetMemberDaimoku(m.MemberID)
let entries = GetMemberEntries(m.MemberID)
let blogs = GetMemberBlogs(m.MemberID)
let encouragements = GetMemberEncouragements(m.MemberID)
let friends = GetMemberFriends(m.MemberID)
let points = GetMemberStats(m.MemberID)
select new Members
{
Row = m.Row,
MemberID = m.MemberID,
Aspnetusername = m.Aspnetusername,
Aspnetpassword = m.Aspnetpassword,
EmailAddr = m.EmailAddr,
DateCreated = m.DateCreated,
Location = m.Location,
DaimokuGoal = m.DaimokuGoal,
PreviewImageID = m.PreviewImageID,
LastDaimoku = m.LastDaimoku.Value,
LastNotefied = m.LastNotefied.Value,
LastActivityDate = m.LastActivityDate.Value,
IsActivated = m.IsActivated,
Details = new LazyList<MemberDetails>(details),
Determinations = new LazyList<MemberDeterminations>(determinations),
Daimoku = new LazyList<MemberDaimoku>(daimoku),
Entries = new LazyList<MemberEntries>(entries),
Blogs = new LazyList<MemberBlogs>(blogs),
Encouragements = new LazyList<MemberEncouragements>(encouragements),
Friends = new LazyList<MemberFriends>(friends),
Stats = new LazyList<MemberStats>(points)
};
return results;
}
}
But for some reason I am getting this error
System.Runtime.Serialization.SerializationException: Type 'System.Data.Linq.DataQuery`1[[DaimokuBeta.MVC.Data.MemberDetails, DaimokuBeta.MVC.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable.
MemberDetails is serializable too..so not sure why it thinks it can't be serialized Any ideas?