Exemple #1
0
        protected Sql GetWith(Sql sql, string paramPrefix)
        {
            int length = withList.Count;
            if (length == 0)
                return sql;

            int i = 0;
            foreach (var with in withList)
            {
                DatabaseProvider.GetParameter(sql, paramPrefix + "v" + i, with.Value);
                DatabaseProvider.GetParameterComparison(sql, with.Key, Relation.Equal, paramPrefix + "v" + i);

                if (i + 1 < length)
                    sql.AddText(",");

                i++;
            }

            return sql;

            //int i = 0, j = 0;

            //return sql
            //    .Join(",", withList.Select(x => DatabaseProvider.GetParameterComparison(x.Key, Relation.Equal, paramPrefix + "v" + i++)).ToArray())
            //    .AddParameters(withList.Select(x => DatabaseProvider.GetParameter(paramPrefix + "v" + j++, x.Value)).ToArray());

            //return new Sql(
            //    string.Join(",", withList.Select(x => DatabaseProvider.GetParameterComparison(x.Key, Relation.Equal, paramPrefix + "v" + i++))),
            //    withList.Select(x => DatabaseProvider.GetParameter(paramPrefix + "v" + j++, x.Value)).ToArray());
        }
Exemple #2
0
        protected Sql GetWith(Sql sql, string paramPrefix)
        {
            int length = withList.Count;
            if (length == 0)
                return sql.AddFormat("VALUES (NULL)");

            sql.AddFormat("({0}) VALUES (", string.Join(",", withList.Keys));

            int i = 0;
            foreach (var with in withList)
            {
                DatabaseProvider.GetParameter(sql, paramPrefix + "v" + i, with.Value);
                DatabaseProvider.GetParameterValue(sql, paramPrefix + "v" + i);

                if (i + 1 < length)
                    sql.AddText(",");
                else
                    sql.AddText(")");

                i++;
            }

            return sql;

            //int i = 0, j = 0;

            //return sql
            //    .AddFormat("({0}) VALUES ({1})",
            //        string.Join(",", withList.Keys),
            //        string.Join(",", withList.Values.Select(x => DatabaseProvider.GetParameterValue(paramPrefix + "v" + i++))))
            //    .AddParameters(withList.Select(x => DatabaseProvider.GetParameter(paramPrefix + "v" + j++, x.Value)).ToArray());

            //return new Sql(
            //    string.Format("({0}) VALUES ({1})",
            //        string.Join(",", withList.Keys),
            //        string.Join(",", withList.Values.Select(x => DatabaseProvider.GetParameterValue(paramPrefix + "v" + i++)))),
            //    withList.Select(x => DatabaseProvider.GetParameter(paramPrefix + "v" + j++, x.Value)).ToArray());

            //return string.Format("({0}) VALUES ({1})",
            //    string.Join(",", withList.Keys),
            //    string.Join(",", withList.Values.Select(x => "'" + x + "'"))
            //);
        }
Exemple #3
0
 internal abstract Sql GetParameterValue(Sql sql, string key);
Exemple #4
0
 internal abstract Sql GetParameterComparison(Sql sql, string field, Relation relation, string key);
Exemple #5
0
 internal abstract Sql GetParameter(Sql sql, string key, object value);
Exemple #6
0
 internal override Sql GetParameterValue(Sql sql, string key)
 {
     return sql.AddFormat("@{0}", key);
 }
Exemple #7
0
 internal override Sql GetParameterComparison(Sql sql, string field, Relation relation, string key)
 {
     return sql.AddFormat("{0} {1} @{2}", field, relation.ToSql(), key);
 }
Exemple #8
0
 internal override Sql GetParameter(Sql sql, string key, object value)
 {
     return sql.AddParameters(new SqlCeParameter("@" + key, value ?? DBNull.Value));
 }
Exemple #9
0
 public abstract Sql GetCommandString(Sql sql, string prefix, int number);
Exemple #10
0
 public abstract Sql GetCommandParameter(Sql sql, string prefix, int number);