示例#1
0
文件: Update.cs 项目: bazer/Modl
        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());
        }
示例#2
0
文件: Insert.cs 项目: bazer/Modl
        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 + "'"))
            //);
        }
示例#3
0
文件: Database.cs 项目: bazer/Modl
 internal abstract Sql GetParameterValue(Sql sql, string key);
示例#4
0
文件: Database.cs 项目: bazer/Modl
 internal abstract Sql GetParameterComparison(Sql sql, string field, Relation relation, string key);
示例#5
0
文件: Database.cs 项目: bazer/Modl
 internal abstract Sql GetParameter(Sql sql, string key, object value);
示例#6
0
 internal override Sql GetParameterValue(Sql sql, string key)
 {
     return sql.AddFormat("@{0}", key);
 }
示例#7
0
 internal override Sql GetParameterComparison(Sql sql, string field, Relation relation, string key)
 {
     return sql.AddFormat("{0} {1} @{2}", field, relation.ToSql(), key);
 }
示例#8
0
 internal override Sql GetParameter(Sql sql, string key, object value)
 {
     return sql.AddParameters(new SqlCeParameter("@" + key, value ?? DBNull.Value));
 }
示例#9
0
文件: QueryPart.cs 项目: bazer/Modl
 public abstract Sql GetCommandString(Sql sql, string prefix, int number);
示例#10
0
文件: QueryPart.cs 项目: bazer/Modl
 public abstract Sql GetCommandParameter(Sql sql, string prefix, int number);