コード例 #1
0
ファイル: DJCUser.cs プロジェクト: WangxuHub/WechatDevelop
        /// <summary>
        /// 执行更新命令
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="oql">对象查询语句</param>
        /// <param name="parameters">参数列表</param>
        /// <returns>影响的记录行数</returns>
        internal static int ExcuteUpdateCommand(SqlCommand cmd, string oql, ParameterList parameters)
        {
            //解析过滤部份Sql语句
            string updateString = SyntaxAnalyzer.ParseSql(oql, new JCUserMap());

            cmd.CommandText = "update JC_User set " + updateString;
            cmd.Parameters.Clear();
            //添加参数
            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
                }
            }
            return(cmd.ExecuteNonQuery());
        }
コード例 #2
0
ファイル: DJCUser.cs プロジェクト: WangxuHub/WechatDevelop
        /// <summary>
        /// 更据对象查询语句递归查询单个实体
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="oql">对象查询语句</param>
        /// <param name="parameters">参数列表</param>
        /// <param name="recursiveType">递归类型</param>
        /// <param name="recursiveDepth">递归深度</param>
        /// <returns>实体对象</returns>
        internal static JCUser ExcuteSelectSingleCommand(SqlCommand cmd, string oql, ParameterList parameters, RecursiveType recursiveType, int recursiveDepth)
        {
            //解析过滤部份Sql语句
            string filterString = SyntaxAnalyzer.ParseSql(oql, new JCUserMap());

            if (filterString != string.Empty)
            {
                filterString = " where " + filterString;
            }
            cmd.CommandText = "select * from JC_User " + filterString;
            cmd.Parameters.Clear();
            //添加参数
            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
                }
            }
            return(ExcuteSelectSingleCommand(cmd, recursiveType, recursiveDepth));
        }
コード例 #3
0
ファイル: DJCUser.cs プロジェクト: WangxuHub/WechatDevelop
        /// <summary>
        /// 执行删除命令
        /// </summary>
        /// <param name="cmd">Command对象</param>
        /// <param name="oql">对象查询语句</param>
        /// <param name="parameters">参数列表</param>
        /// <returns>影响的记录行数</returns>
        internal static int ExcuteDeleteCommand(SqlCommand cmd, string oql, ParameterList parameters)
        {
            //解析过滤部份Sql语句
            string filterString = SyntaxAnalyzer.ParseSql(oql, new JCUserMap());

            if (filterString != string.Empty)
            {
                filterString = " where " + filterString;
            }
            cmd.Parameters.Clear();
            cmd.CommandText = "delete from JC_User " + filterString;
            //添加参数
            if (parameters != null)
            {
                foreach (string key in parameters.Keys)
                {
                    cmd.Parameters.Add(new SqlParameter(key, parameters[key]));
                }
            }
            return(cmd.ExecuteNonQuery());
        }