Guys,
We have a lot of code in some ASP.NET user controls such as this
/// <summary>
/// Saves the SI head attachment.
/// </summary>
private void SaveSIHeadAttachment() {
// Save record in Attachment table
AttachmentEntity attachment = GetAttachmentObjectFromFormData();
if (attachment.Save()) {
// save record in link table
SiheadAttachmentEntity siHeadAttachment = new SiheadAttachmentEntity();
siHeadAttachment.AttachmentId = attachment.AttachmentId;
siHeadAttachment.SiheadId = AttachmentEntityKey;
siHeadAttachment.Save();
}
}
/// <summary>
/// Saves the transaction line attachment for PO and SI Line.
/// </summary>
private void SaveTransactionLineAttachment() {
// Save record in Attachment table
AttachmentEntity attachment = GetAttachmentObjectFromFormData();
if (attachment.Save()) {
// save record in link table
TransactionLineAttachmentEntity lineAttachment = new TransactionLineAttachmentEntity();
lineAttachment.AttachmentId = attachment.AttachmentId;
lineAttachment.TransactionLineId = AttachmentEntityKey;
lineAttachment.Save();
}
}
This is in attachment UserControl which attaches files to documents e.g. invoices / purchase orders.
The code is the part which links the actual document to the attachment entity.
Can anyone think of a useful way to refactor using the LLBLGen code? I was thinking interfaces would be a useful approach e.g. IDocumentAttachmentLink interface containing two properties
AttachmentId
DocumentId
Each entity could implement the interface and the UserControl could write code based on the interface.
Could we generate these interfaces or add them through the LLBLGen generated code? If so what are the best approaches to do this, we use SelfServicing and additional partial classes to extension the base entities.