Dhominator wrote:
Is the Adapter approach [basically] a given for multiple DBMSes?
IMO Yes
Dhominator wrote:
Mainly lose lazy load for relations? (same schema all DBMSes)
But you gain so much more control with respect to how your application services clients that the tradeoff is well worth it, i.e. you can now snap in remoting, web services, or COM+ to provide the implementation of your DAL. This is much more powerful (for me anyway.)
Dhominator wrote:
Any patterns/hacks for supporting lazy load w/Adapter approach (maybe entity-based events)?
I beleive that what a lot of people do is use controller classes. There are controller template parsers available that build all of the common fetch, save, and delete methods for all entities in an llblgen project. So ultimately you end up with code like this:
string customerId = "1234";
CustomerEntity customer = CustomerController.Fetch(customerId);
customer.FirstName = "Bob";
if CustomerController.SaveEntity(customer)
{
MessageBox.Show("Customer Updated");
}
I am in the process of taking controller classes to the next level to enable COM+ in the controllers.
Dhominator wrote:
If I want to cache a few readonly entities (typed lists) on the client how does this fit into the architecture/approach? #1 Assume simplest thing that could possible work... serialized typed lists as local cache. #2 some other format.
Xin Chen has a book titled developing application frameworks in .NET that demonstrates a straightforward and simple caching service that would fit the bill perfectly. You could even plug in your own storage mechanism if you like. (i.e. use IIS caching instead of the default hashtable approach). The caching framework also uses XML and XPath assist developers in locating cached items.
Here is an exerpt from his book, slightly modified for demonstration with LLBLGen:
static void Main(string[] args)
{
//get the cache object
Cache cache = SAF.Cache.Cache.GetSAFCacheService();
ControllerBase tmpController = ControllerFactory.GetController("UserEntityController");
UserEntity tmpUser;
TypedList tmpCustomerOrders;
//add some objects into the cache service
tmpUser = tmpController.FetchEntity(1);
cache.AddObject("/WebApplication/UserEntity/1", tmpUser);
tmpUser = tmpController.FetchEntity(2);
cache.AddObject("/WebApplication/UserEntity/2", tmpUser);
tmpUser = tmpController.FetchEntity(3);
cache.AddObject("/WebApplication/UserEntity/3", tmpUser);
tmpController = ControllerFactory.GetController("CustomerOrdersTypedListCustomController");
tmpCustomerOrders = ((CustomerOrdersTypedListCustomController)tmpController).OrdersByCustId("ABC123");
cache.AddObject("/WebApplication/TypedList/CustomerOrders/ABC123", tmpCustomerOrders);
//retrieve the objects as a group
object[] objects = cache.RetrieveObjectList("/WebApplication/UsersEntity");
foreach (object o in objects)
{
Console.WriteLine("User in cache: {0}", ((UserEntity)o).FirstName);
}
//retrieve the object as individual
string time =(string) cache.RetrieveObject("/WebApplication/GlobalData");
string name = (string) cache.RetrieveObject("/WebApplication/Users/Xin");
//remove the object
cache.RemoveObject("/WebApplication/TypedList/CustomerOrders/ABC123");
//remove all the object under /Users
cache.RemoveObject("/WebApplication/UsersEntity");
}
The code
Cache cache = SAF.Cache.Cache.GetSAFCacheService();
creates a thread safe singleton object.