Epiworx.Data.EntityFramework.AttachmentDataFactory.Insert C# (CSharp) Method

Insert() public method

public Insert ( AttachmentData data ) : AttachmentData
data AttachmentData
return AttachmentData
        public AttachmentData Insert(AttachmentData data)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                           .GetManager(Database.ApplicationConnection, false))
            {
                var attachment = new Attachment();

                DataMapper.Map(data, attachment);

                ctx.ObjectContext.AddToAttachments(attachment);

                ctx.ObjectContext.SaveChanges();

                data.AttachmentId = attachment.AttachmentId;

                return data;
            }
        }