I have a business object with 20+ properties. And child having 15+ properties which is a Businesslistbase. I require the Root object property values in updating some child property values.
When I use linq to sql and pass the root object in the Dataportal_Update() method like below
<Transactional(TransactionalTypes.TransactionScope)> _
Protected Overrides Sub DataPortal_Update()
Using ctx = ContextManager(Of DalLinq.DartDBDataContext).GetManager(connection, False)
ctx.datacontext.Root.updateRootStoredProcedure( propertvalue1, propertyvalue2, 3, 4 .....)
Fieldmanager.UpdateChildren(me)
End using.
End sub
and in the Child_Update() method in the child object I can not read the values of the Root object.
It gives the error like "property evaluation failed "
"Cannot evaluate expression because we are stopped in a place where garbage collection is impossible"
Is there a way to solve this problem?
But If I take out the using statements and linq update methods at both Root and Child,
and just used the FieldManager.UpdateChildren(me) method , I can read the root object values inside the Child_Update method.
When do you call ctx.datacontext.SubmitChanges()?
Do you use callbacks to update primary key values in the business object?
When do you call ctx.datacontext.SubmitChanges()?
Do you use callbacks to update primary key values in the business object?
Thanks for replying.
No. I use storedprocedures and reference variable to update the timestamp and primary key values back to the objects as in ProjectTracker.Library. Will try without stored procedures. And will get back.
Finally I found out the reason.
I was using storedprocedure with linq like this
ctx.datacontext.Root.updateRootStoredProcedure( Root.propertvalue1, Root.propertyvalue2, 3, 4 ... Child.Propertyval1, Child.Propertyvalue2 ......) - with arguments numbering 30+.
with these I was getting the message - property evaluation failed when try to read the rootobject propertis, even child's own properties inside the function.
I tried to convert the function arguments to construct sql parameters to work with normal sql ado command object (instead of using Linq). This one also failed to read and gave the same error message.
But if I modified the function with less arguments like the one below - it worked.
private sub constructinsertParameters(byval cmd as sqlcommand, byval Root as MyBOClass , Byval child as MyChildClass)
with cmd.parameters
.addwithvalue("@param1", root.propertyvalue1)
.addwithvalue("@param2", root.propertyvalue2)
.
.
.
.
end with
End Sub
But it tool whole day to find out the reason. Hope it will help somebody avoid wasting time like me who may a newbee like me. .
Copyright (c) Marimer LLC