If I have an InvoiceEntity class which holds a collection of InvoiceItemEntity and InvoiceItemEntity implements ICustomDisplayOrder which looks like this:-
public interface ICustomDisplayOrder
{
int? DisplayOrder { get; set; }
}
(DisplayOrder is an entity field BTW)
What I basically want to do is have DisplayOrder automatically get set when an xxxItem gets added to its parent collection. It should be set to the parent collection's .Count property to put it at the end of the list. So it needs to obtain the parent collection it is contained in somehow.
I have a few situations like the above and want to find a solution that can be generically reused.
I am happy to extend ICustomDisplayOrder or add an interface to the parent entity or write custom code in either parent or child to achieve this.
Updating when saving is not the best solution since the items will be displayed in a grid in the meantime.
The solution needs to be able to cope with entities being added to the collection directly or via AddNew or AddRange and binding etc.
There is a _parentCollection on EntityBase2 but it has been locked down so I don't know if that is usable (happy to use reflection if it is).
What can you suggest?
LLBLGen 4.0 July 18th