Beispiel #1
0
        private void DeleteSQL(DatabaseCore accessor, out string sql, out List <DbParameter> parameters)
        {
            sql        = null;
            parameters = null;
            if (accessor == null)
            {
                return;
            }


            if (Keys == null || Keys.Count <= 0)
            {
                return;
            }
            var temp = string.Format("DELETE FROM {0}", TableName);

            var select = new StringBuilder();

            var where = new StringBuilder();
            var list = new List <DbParameter>();

            foreach (string key in Keys.Keys)
            {
                if (where.Length > 0)
                {
                    where.AppendLine("AND");
                }
                var parameter = accessor.CreateParameter(Keys[key]);
                where.AppendLine(string.Format("{0} = {1}", key, parameter.ParameterName));
                list.Add(parameter);
            }

            select.AppendLine(temp);
            if (where.Length > 0)
            {
                select.AppendLine("WHERE");
                select.AppendLine(where.ToString());
            }

            parameters = list;
            sql        = select.ToString();
        }
Beispiel #2
0
        public void Export(DatabaseCore accessor, out string clause, out List <DbParameter> parameters)
        {
            clause = null; parameters = null;
            if (accessor == null)
            {
                return;
            }
            var temp = text;
            var list = new List <DbParameter>();

            this.parameters.Keys.ToList().ForEach(key =>
            {
                var naked = NakedName(key);
                var param = accessor.CreateParameter(naked, this.parameters[key]);
                temp      = temp.Replace(key, param.ParameterName);
                list.Add(param);
            });
            clause     = temp;
            parameters = list;
        }