Ticket Q397193
Visible to All Users

File Attachment in Domain Component

created 13 years ago

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,

Comments (1)
S S
SWAPI - Alziro Moraes 13 years ago

    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,

    Answers

    created 13 years ago (modified 13 years ago)

    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

      Comments (2)
      S S
      SWAPI - Alziro Moraes 13 years ago

        I currently use FileData, not IPersistentFileData.
        Example: FileData Attach {get; set;}
        Is that correct?

        Anatol (DevExpress) 13 years ago

          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.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.