コード例 #1
0
        private void DeleteAll <T>(CriteriaNode criteriaNode) where T : new()
        {
            var deleteSql = ClassConfigContainer.FindDeleteSql(typeof(T));

            try
            {
                Command.Start();

                var criterias = criteriaNode.SearchAll();

                if (criterias.Count > 0)
                {
                    UpdateCriteria <T>(criterias);
                }

                if (Shared.IsAuditable <T>())
                {
                    var originalObjects = RetrieveAll <T>(criteriaNode);

                    var dict = new Dictionary <T, string>();

                    foreach (var original in originalObjects)
                    {
                        string updateSql = ClassConfigContainer.FindUpdateSql1(typeof(T));

                        var propertyParameters =
                            ParametersCreator.CreatePropertyParameters(ParameterPrefix,
                                                                       original, ref updateSql);

                        string auditText = Auditor.AuditDelete(original, propertyParameters);

                        dict[original] = auditText;
                    }

                    ExecuteNonQuery(deleteSql, criteriaNode);

                    foreach (var original in originalObjects)
                    {
                        InsertAuditRecord(original, DbOperation.Delete, dict[original]);
                    }
                }
                else
                {
                    ExecuteNonQuery(deleteSql, criteriaNode);
                }
            }

            catch (Exception ex)
            {
                throw CreateEasylinkException(deleteSql, ex);
            }
        }