Esempio n. 1
0
        public bool SetAttachmnetsRemoved(IAttachmentsExp exp)
        {
            var query = new SqlUpdate(AttachmentTable.TABLE_NAME.Alias(AttachmentTable.TABLE_NAME))
                        .InnerJoin(MailTable.TABLE_NAME.Alias(MailTable.TABLE_NAME),
                                   Exp.EqColumns(MailTable.Columns.Id.Prefix(MailTable.TABLE_NAME),
                                                 AttachmentTable.Columns.MailId.Prefix(AttachmentTable.TABLE_NAME)))
                        .Set(AttachmentTable.Columns.IsRemoved, true)
                        .Where(exp.GetExpression());

            var result = Db.ExecuteNonQuery(query);

            return(result > 0);
        }
Esempio n. 2
0
        public List <Attachment> GetAttachments(IAttachmentsExp exp)
        {
            var query = Query(AttachmentTable.TABLE_NAME)
                        .InnerJoin(MailTable.TABLE_NAME.Alias(MailTable.TABLE_NAME),
                                   Exp.EqColumns(MailTable.Columns.Id.Prefix(MailTable.TABLE_NAME),
                                                 AttachmentTable.Columns.MailId.Prefix(AttachmentTable.TABLE_NAME)))
                        .Select(MailTable.Columns.Stream.Prefix(MailTable.TABLE_NAME),
                                MailTable.Columns.User.Prefix(MailTable.TABLE_NAME))
                        .Where(exp.GetExpression());

            return(Db.ExecuteList(query)
                   .ConvertAll(ToAttachment));
        }
Esempio n. 3
0
        public long GetAttachmentsSize(IAttachmentsExp exp)
        {
            var query = new SqlQuery(AttachmentTable.TABLE_NAME.Alias(AttachmentTable.TABLE_NAME))
                        .InnerJoin(MailTable.TABLE_NAME.Alias(MailTable.TABLE_NAME),
                                   Exp.EqColumns(MailTable.Columns.Id.Prefix(MailTable.TABLE_NAME),
                                                 AttachmentTable.Columns.MailId.Prefix(AttachmentTable.TABLE_NAME)))
                        .SelectSum(AttachmentTable.Columns.Size.Prefix(AttachmentTable.TABLE_NAME))
                        .Where(exp.GetExpression());

            var size = Db.ExecuteList(query)
                       .ConvertAll(r => Convert.ToInt64(r[0]))
                       .FirstOrDefault();

            return(size);
        }
Esempio n. 4
0
        public int GetAttachmentsCount(IAttachmentsExp exp)
        {
            var query = new SqlQuery(AttachmentTable.TABLE_NAME.Alias(AttachmentTable.TABLE_NAME))
                        .InnerJoin(MailTable.TABLE_NAME.Alias(MailTable.TABLE_NAME),
                                   Exp.EqColumns(MailTable.Columns.Id.Prefix(MailTable.TABLE_NAME),
                                                 AttachmentTable.Columns.MailId.Prefix(AttachmentTable.TABLE_NAME)))
                        .SelectCount(AttachmentTable.Columns.Id.Prefix(AttachmentTable.TABLE_NAME))
                        .Where(exp.GetExpression());

            var count = Db.ExecuteList(query)
                        .ConvertAll(r => Convert.ToInt32(r[0]))
                        .SingleOrDefault();

            return(count);
        }