Csla 6.2.2 - LazyGetProperty(Async) #3250
-
Hi, Furthermore a request to confirmation. First Question
Second Question Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
When lazy loading a child object, you should use a command pattern to invoke the data portal on a root object (the command). The child data portal does NOT move the call from client to the logical server, so you should NOT be calling the child data portal directly. That causes the problems you describe, plus it will fail if you ever switch to an n-tier deployment. The command class can look something like this: [Serializable]
public class ChildGetter : ReadOnlyBase<ChildGetter>
{
// declare standard CSLA property for Child - pseudo-code here:
cslaprop ChildType Child { get; set; }
[Create]
private void Create([Inject] IChildDataPortal<Child> dp)
{
Child = dp.CreateChild();
}
[Fetch]
private void Fetch(int id, [Inject] IChildDataPortal<Child> dp)
{
Child = dp.FetchChild(id);
}
} Then in your lazy load property implementation, use an What happens is that the ChildGetter does move the the logical server, and then it is able to call the child data portal on the logical server, where things are disposed properly, etc. The |
Beta Was this translation helpful? Give feedback.
When lazy loading a child object, you should use a command pattern to invoke the data portal on a root object (the command).
The child data portal does NOT move the call from client to the logical server, so you should NOT be calling the child data portal directly. That causes the problems you describe, plus it will fail if you ever switch to an n-tier deployment.
The command class can look something like this: