Hi,
I would like some tips on handling link tables. I am having some problems making sense of LLBLGen Pro and the way it handles entities in relation to related entries. To demonstration the senario here is an example schema of the data
Attribute <---- Property_Attribute ----> Property <---- PropertyTypeLink --->PropertyType
The property_Attribute and PropertyTypeLink are link tables and just contain a pair of foreign keys to convert M:N relationships to a pair of 1:M relationships. The Property entity also has a foreign key to the resort entity. A UI(Web page) has a grid view and details view. The details view has a drop down template field to convert the Property.resort_id to a resortname. Their are a set of standard Save, New and Delete Buttons at the bottom of the page.
I use separate LLBLGenPro2 datasources to feed the gridview, detailsview and resort dropdownlist. Live persistance is set to true for the gridview and resort drop down list, false for the detialsview. All the necessary event methods are set up including the Perform_Work for the details view.
The question is what approach would be best to Create,Update and Delete items and any associated link entiries.
I update the resort_id from the selectedvalue in the dropdown list prior to saving.
The associated entries in the link tables are cleared the the new associations add entity by entity. I use DeleteDirect and a RelationPredicate which targets only the related entries e.g. For attributes linked to a property
RelationPredicateBucket theRPB = new RelationPredicateBucket();
theRPB.PredicateExpression.Add(new PredicateExpression(PropertyAttributeLinkFields.PropertyId == theProperty.PropertyId));
da.DeleteEntitiesDirectly("PropertyAttributeLinkEntity", theRPB);
There must be a better way than hard coding the entity name.
I had a look at relations such as
theProperty.PropertyTypeCollectionViaPropertyTypeLink
This is a read only list of attributes and only appears to be useful for population the associations
I am using the current set of libraries and tools
[code]LBLGenPro version 2.0.0.0 Final
Runtime Libs 2.0.0.0
DQE.Sql.Net.2.0 File version: 2.0.7.129
ORM.Support File version: 2.0.7..402[
Adapter DB interface/code]