This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Dears, we are facing a problem after installing Version 3.1. here is sample of the code we are writting
if
(!Page.IsPostBack)
{ using (LightSpeedModel1UnitOfWork db = _context.CreateUnitOfWork())
{
ViewState[ "F"] = db.Banks.ToList();
} }
else {
Bank area = new Bank ();
area.NameAr = "fff" ;
List<Bank> areas = (List<Bank>)ViewState["F" ];
areas[0].NameAr = "ggg" ;
} the code is crashing at areas[0].NameAr = "ggg"
with this stack trace " at Mindscape.LightSpeed.Entity.TrackChange(String , Object , Object )\r\n at Mindscape.LightSpeed.Entity.SetInternal[TField](TField& , TField , String )\r\n at Mindscape.LightSpeed.Entity.Set[TField](TField& field, TField value, String propertyName)\r\n at WebApplication1.Bank.set_NameAr(String value) in C:\\Datel\\WebApplication1\\WebApplication1\\LightSpeedModel1.cs:line 49\r\n at WebApplication1._Default.Page_Load(Object sender, EventArgs e) in C:\\Datel\\WebApplication1\\WebApplication1\\Default.aspx.cs:line 38\r\n at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)\r\n at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n at System.Web.UI.Control.OnLoad(EventArgs e)\r\n at System.Web.UI.Control.LoadRecursive()\r\n at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)" |
|
|
This looks like a serialisation issue. I'll flag this up to the relevant person, but it looks like change tracking is not available on entities that are deserialised as opposed to being constructed or loaded normally. The solution is not to store entities in viewstate (or session state). Instead, store the entity ID, and reload the entity from the database during page load. |
|
|
Sorry, this issue will affect you even if you're not using change tracking. My mistake. Nevertheless, the remedy is the same: don't serialise entities into viewstate or session state, store the IDs instead and reload them on the next request. |
|
|
This was fixed in a recent nightly build. If you grab the latest nightly build it will work for you :-) Having said that, you'll be adding a lot of weight to the page potentially so Ivan's suggestion of only storing entity id's is a good one. John-Daniel |
|