Ejemplo n.º 1
0
        public static DbQuery SimpleDelete <T>(QueryCondition conditioins)
        {
            var res = new DbQuery();
            var t   = typeof(T);

            res.Sql.AppendFormat(DELETE_FORMAT, t.Name);
            conditioins.BuildSqlWhere(res, t.Name);
            return(res);
        }
Ejemplo n.º 2
0
        public static DbQuery SimpleSelect(string tableName, QueryCondition queryCondition, int?count = null)
        {
            var res = new DbQuery();

            res.Sql.AppendFormat("Select {1} * from [{0}] ", tableName, count.HasValue ? " TOP " + count : "");
            if (queryCondition != null)
            {
                queryCondition.BuildSqlWhere(res, tableName);
            }
            return(res);
        }
Ejemplo n.º 3
0
        private static DbQuery SimpleUpdate(Type t, IDictionary <string, object> updateParams,
                                            IDictionary <string, string> updateParamsMapper, QueryCondition queryCondition)
        {
            var res = new DbQuery {
                Parameters = new Dictionary <string, object>()
            };

            res.Sql.Append("Update [").Append(t.Name).Append("] set");
            res.Sql.Append(updateParams.Select(x => "[" + updateParamsMapper[x.Key] + "]=@" + x.Key).JoinString(","));

            foreach (var updateParam in updateParams)
            {
                if (!res.Parameters.ContainsKey(updateParam.Key))
                {
                    res.Parameters.Add(updateParam);
                }
            }
            queryCondition.BuildSqlWhere(res, t.Name);
            return(res);
        }