Context:
General:
We use the LLBLgen designer version 3.5, the LLBLgen framework and the LLBLgen OData provider to expose our business model for client applications.
Business model:
Within the LLBLgen designer we created an entity model based on our Business. This model contains our functional business entities, business properties and the business relations necessary for our client applications. It contains no database specific information other than a pk property and fk relations. Each entity contains also an external generated business type id which is necessary for client notifications. The business type id was added as a partial class property.
Physical model database:
The database has his own complex physical data model and contains specific business logic for different issues and subjects like “database synchronization” and “project authorization”. The interface to the ORM is implemented by database views and stored procedures. The view is used for the retrieve (R) action and the specific create, update and delete (CUD) actions are done by stored procedures.
Mapping/Interfacing database with LLBLgen ORM framework:
The LLBLgen framework with its business objects are mapped with the database by the database views and its stored procedures. There is a specific mapping for each business entity. This is implemented by one database view and three stored procedures. The mapping of the database View can easily be mapped in the designer by the Field Mappings tab and then the Target selection. The view can be selected in the Target drop down box witch is available for each entity. The CUD actions on the other hand are implemented using the LLBLgen framework Adapter model. The CUD actions are implemented in the Adapter class by a override of the CreateInsertDQ, CreateUpdateDQ, CreateDeleteDQ methods, see the included code:
protected override IActionQuery CreateInsertDQ(IEntity2 entityToSave, IFieldPersistenceInfo[] persistenceInfoObjects)
{
ActionQuery_SPCreate query = new ActionQuery_SPCreate(this, entityToSave);
return query;
}
protected override IActionQuery CreateUpdateDQ(IEntity2 entityToSave, IFieldPersistenceInfo[] persistenceInfoObjects, List<IPredicate> pkFilters)
{
ActionQuery_SPUpdate query = new ActionQuery_SPUpdate(this, entityToSave);
return query;
}
protected override IActionQuery CreateDeleteDQ(IFieldPersistenceInfo[] fieldsPersistenceInfo, List<IPredicate> pkFilters)
{
Predicate predicate = (Predicate)pkFilters.First();
FieldCompareValuePredicate fcvp = (FieldCompareValuePredicate)((PredicateExpression)predicate).First().Contents;
string tableName = fcvp.PersistenceInfo.SourceObjectName;
long recordId = (int)fcvp.Value;
ActionQuery_SPDelete query = new ActionQuery_SPDelete(null, this, tableName, recordId);
return query;
}
The CUD Stored Procedure calls itself (not shown here) are implemented in the ActionQueries of the CreateXXDQ methods. Both the CreateInsertDQ and CreateUpdateDQ where very simple to implement because they have all the business properties of the entity available there. And also the additional business type ID is available there to be redirected to the stored procedure as a parameter. A second stored procedure parameter is used for concurrency control and is also be implemented here, no problem.
Issue:
But we have a problem with the CreateDeleteDQ method. It contains no reference to the instance who he supposed to be delete. The ID and the entity/table name can be found using some additional steps, see above. But the property values cannot be found and used here. Is there a hook to get it available?