Exemplo n.º 1
0
        public bool DeleteOldMessages(UserVO from, UserVO to)
        {
            List <MessageVO> m = GetMessages(from, to);

            if (m.Count <= ConfigurationManager.MAXIMUM_MESSAGES_COUNT)
            {
                return(true);
            }

            m.Sort(new MessageSorter());
            int       firstOldMessageIndex = m.Count - 1 - ConfigurationManager.MAXIMUM_MESSAGES_COUNT;
            MessageVO firstOldMessage      = m[firstOldMessageIndex];
            DateTime  toDeleteDate         = firstOldMessage.Date;
            string    condition            = string.Format("({0} <= @{0} and {1}=@{1} and {2}=@{2})", messageDate, messageFrom, messageTo);
            string    statement            = SqlStatememtGenerator.Delete_ByCondition(tableName, condition);

            SqlParameter[] parameters =
            {
                MakeSqlParameter(messageDate, toDeleteDate, SqlDbType.DateTime),
                MakeSqlParameter(messageFrom, from.Id),
                MakeSqlParameter(messageTo,   to.Id)
            };

            return(executer.ExecuteDeleteStatement(statement, parameters));
        }
Exemplo n.º 2
0
        private bool DeleteAssociationsOfTableElement(VO tableElement, string providedTableColumnName)
        {
            string condition = string.Format("{0} = @{0}", providedTableColumnName);
            string statement = SqlStatememtGenerator.Delete_ByCondition(tableName, condition);

            SqlParameter[] parameters = new SqlParameter[] { MakeSqlParameter(providedTableColumnName, tableElement.Id) };

            return(executer.ExecuteDeleteStatement(statement, parameters));
        }
Exemplo n.º 3
0
        public bool Detach(T1 firstTableVO, T2 secondTableVO)
        {
            string condition = string.Format("{0} = @{0} and {1} = @{1}", firstTableIdColumnName, secondTableIdColumnName);
            string statement = SqlStatememtGenerator.Delete_ByCondition(tableName, condition);

            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = MakeSqlParameter(firstTableIdColumnName, firstTableVO.Id);
            parameters[1] = MakeSqlParameter(secondTableIdColumnName, secondTableVO.Id);

            return(executer.ExecuteDeleteStatement(statement, parameters));
        }
Exemplo n.º 4
0
        public virtual bool DeleteAll()
        {
            string statement = SqlStatememtGenerator.Delete_ByCondition(tableName, "1=1");

            return(executer.ExecuteDeleteStatement(statement, null));
        }