Beispiel #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);
            }
        }
Beispiel #2
0
        private List <T> RetrieveAll <T>(CriteriaNode criteriaNode) where T : new()
        {
            var selectSql = ClassConfigContainer.FindSelectSql <T>();

            var criterias = criteriaNode.SearchAll();

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

            var table = RetrieveTable(selectSql, criteriaNode);

            return(ObjectMapper.MapTableToList <T>(table));
        }
Beispiel #3
0
        private string CreateWhereClause(CriteriaNode criteriaNode)
        {
            var criterias = criteriaNode.SearchAll();

            if (criterias.Count == 0)
            {
                return(string.Empty);
            }

            if (criteriaNode.Criteria != null)
            {
                return(CreateCondition(criteriaNode.Criteria));
            }

            return(string.Format("({0} {1} {2})", CreateWhereClause(criteriaNode.LeftChild), criteriaNode.NodeType,
                                 CreateWhereClause(criteriaNode.RightChild)));
        }