How to implement File Attachment property in Domain Component?
I try and doesn't work:
[DomainComponent, DefaultClassOptions, XafDefaultProperty("NotaFiscal"), ImageName("BO_Sale"), FileAttachment("Anexo")]
public interface IEntrada : IMovimentacao
{
[RuleRequiredField("Preencher A Nota Fiscal", DefaultContexts.Save, CustomMessageTemplate = "O campo {TargetPropertyName} deve ser preenchido."), DisplayName("Nota Fiscal")]
string NotaFiscal { get; set; }
IFornecedor Fornecedor { get; set; }
IFuncionario EntradaPor { get; set; }
IList<IEntradaItem> Produtos { get; }
IFileData Anexo { get; set; }
}
Thks,
File Attachment in Domain Component
Answers
Hello Alziro,
The IFileData interface does not work, because it is not a domain component. We have a special domain component for this - IPersistentFileData. Please use it to add file attachments to your domain components.
To add a collection of file attachments, implement the IFileAttachment domain component with a reference to the IPersistentFileData instance and add an IList<IFileAttachment> property to the required DC.
Thanks,
Anatol
I currently use FileData, not IPersistentFileData.
Example: FileData Attach {get; set;}
Is that correct?
Currently, references to persistent classes inside domain components work correctly. However, if you wish to attach multiple files to a domain component, you will need to use DC file data to be able to establish a one-to-many association.
Hi,
I see my little mistake. I change to and work:
[DomainComponent, DefaultClassOptions, XafDefaultProperty("NotaFiscal"), ImageName("BO_Sale")]
public interface IEntrada : IMovimentacao
{
[RuleRequiredField("Preencher A Nota Fiscal", DefaultContexts.Save, CustomMessageTemplate = "O campo {TargetPropertyName} deve ser preenchido."), DisplayName("Nota Fiscal")]
string NotaFiscal { get; set; }
IFornecedor Fornecedor { get; set; }
IFuncionario EntradaPor { get; set; }
IList<IEntradaItem> Produtos { get; }
FileData Anexo { get; set; }
}
But how do I implement a list of files and not only one?
All samples are using Domain Objects (http://documentation.devexpress.com/#Xaf/CustomDocument2658)
Thks,