Hi there,
We've built a DAL around LLBLGEN 2.6, and this DAL is used across several projects.
The requirement has recently come up to be able to swap out the real SQL Server database with an in-memory database. This would be activated in a so-called "demo mode". In this mode, no data would be persisted to real storage.
In order to make this change, i'm implementing a custom DataAccessAdapter which just uses an IDictionary<EntityType, IEntityCollection2> as the storage mechanism, and swapping out the real DataAccessAdapter for our demo mode data adapter. Here, EntityType is the Type of my entity objects (eg typeof(CustomerEntity)) and IEntityCollection2 is just a container for all objects stored using SaveEntity
I've successfully implemented a basic subset of the functionality and for the most part this works. However, my current implementation of FetchEntity is quite dumb, and doesn't take into account related entity collections when fetching a record from the dictionary.
Because of the nature of FetchEntity being that it will populate the provided IEntity2 object, what I need is a way to be able to "deep clone" an object pulled out from the dictionary INTO the object provided to FetchEntity. The deep clone code i've found elsewhere on this forum will create a separate copy, NOT copy the values into a provided object so it's not entirely helpful
Some code, to give you an idea of what i'd like:
//_entityStore is a thin wrapper over IDictionary<Type, IEntityCollection2>
public bool FetchEntity(IEntity2 entityToFetch)
{
var found = _entityStore.FindEntityByPk(entityToFetch);
if (found != null)
{
entityToFetch.Fields = found.Fields.Clone();
_entityToFetch.Relations = found.Relations.Clone();
return true;
}
return false;
}
For clarity - i'm not specifically requesting that implementation above, but asking what ways are there to clone the found entity INTO the entityToFetch?
Cheers,
Xerx
EDIT: just some clarifications