I have a potential application that will run on a device that may be disconnected for long periods of time, so it will always need a local data store. For times when it is connected, it will also communicate with an application server.
There will also be times when it needs to read data from the application server for caching in the local data store, so it's possible for both to be active at the same time.
I'd like to use CSLA objects for both the local and remote data, but don't see how to do this. I did search and found some references to multiple portals, but it seems these were controlled with a global switch of some sort.
In my case, the BO itself will determine which portal is be used, not some other sort of switch. Some BO's will always be local, others will always be managed by the application server.
Is this feasible?
To simplify, if I could control which data portal is used at an assembly level instead of the . EXE, that would be fine also.
Proper solution would be to write your own data portal. In
this case your business objects could somehow register themselves with portal,
including object type and what type of proxy they want.
On the other hand, if you can assure that one object calls data
portal at a time (no asynchronous or overlapping calls at all), you can use a
cheap hack and call the following prior to all data portal calls, including
Update (that is called from Save()): ConfigurationManager.AppSettings["CslaDataPortalProxy"] = “Local”
// or WCF or whatever
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Magenic ®
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: rsbaker0
[mailto:cslanet@lhotka.net]
Sent: Tuesday, November 11, 2008 8:52 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] Using a local and remote data portal (e.g. 2
data portals) at the same time?
To simplify, if I could control which data portal is used at an assembly
level instead of the . EXE, that would be fine also.
Did you mean write my own data portal proxy?
I'm looking at it (and have searched some more since my original post), but there would seem to be an issue in that DataPortalContext is constructed before the proxy is aware of what type it would be working with, so IsServerRemote might not have the right value.
Nope, I actually was thinking Data Portal itself. I think
you do not need to override proxy as you will be using either Local or
WCF(Remoting, etc…) proxy, and those would be as they are in CSLA.
In your case the part that would change would be GetDataPortalProxy that would
need to account for object type probably as well as RunLocal attribute (if you
are using it). This maybe more that what you are bargaining for though…
In this case I would go back to suggested hack…
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: rsbaker0
[mailto:cslanet@lhotka.net]
Sent: Tuesday, November 11, 2008 10:06 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Using a local and remote data portal (e.g.
2 data portals) at the same time?
Did you mean write my own data portal proxy?
I'm looking at it (and have searched some more since my original post), but
there would seem to be an issue in that DataPortalContext is constructed before
the proxy is aware of what type it would be working with, so IsServerRemote
might not have the right value.
True. I was thinking of you actually modifying the CSLA
DataPortal class. Not that I would myself encourage that or anything J.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: rsbaker0
[mailto:cslanet@lhotka.net]
Sent: Tuesday, November 11, 2008 11:02 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: RE: Using a local and remote data portal
(e.g. 2 data portals) at the same time?
Hmmm. I don't see how CSLA supports replacing the entire
data portal itself (especially if I don't have the luxury of modifying one of
the business object assemblies).
I've looked at the code some more. There are only 4 calls to GetDataPortalProxy() in the entire code base (Csla 3.5.1).
Perhaps if Rocky could add a simple mechanism here to (1) allow substitution of an alternative proxy provider, and (2) pass in the type of the object when calling the GetDataPortalProxy() and make this available to the provider, then I'd think an almost arbitrary proxy configuration could be implemented.
I'm not sure what the best or preferred way to implement a substitute provider would be. You could have a static method that takes a delegate, or perhaps a static event like OnGetDatatPortalProxy that could be subscribed to. The subscriber could return the desired proxy in the event args. If no alternative provider has been specified, the behavior could default to the current mechanism.
Copyright (c) Marimer LLC