Example #1
0
        protected virtual TCmd BuildDelete()
        {
            TCmd cmd = new TCmd();

            cmd.CommandText = "DELETE FROM " + SqlTable
                              + (SqlConditionals.Count == 0 ? ""
                    : " WHERE " + SqlConditionals.Select(sc => sc.Replace("@", "@" + ParamUniqueKey)).Join(" AND "));
            SetParameters(cmd);

            return(cmd);
        }
Example #2
0
        protected virtual TCmd BuildUpdate()
        {
            if (SqlSets.Count == 0)
            {
                return(null);
            }

            TCmd cmd = new TCmd();

            cmd.CommandText = "UPDATE " + SqlTable
                              + " SET "
                              + SqlSets.Where(kvp => !PreservedFields.Contains(kvp.Key))
                              .Select(kvp => QuoteName(kvp.Key) + " = @" + ParamUniqueKey + "S_" + kvp.Key)
                              .Join(", ")
                              + (SqlConditionals.Count == 0 ? ""
                    : " WHERE " + SqlConditionals.Select(sc => sc.Replace("@", "@" + ParamUniqueKey)).Join(" AND "));
            SetParameters(cmd);
            SetUpdateParameters(cmd, true);

            return(cmd);
        }