Ejemplo n.º 1
0
        /// <summary>
        /// 生成 DELETE FROM [TableName] WHERE [condition1]=@condition1 AND [condition2]=@condition2
        /// </summary>
        /// <param name="model">载有生成信息的Model</param>
        /// <param name="conditions">需要匹配的成员集合</param>
        /// <returns>删除字符串结果</returns>
        public string DeleteWithCondition(SqlModel model, params string[] conditions)
        {
            StringBuilder     sql      = new StringBuilder(Delete(model));
            ConditionTemplate template = new ConditionTemplate();

            sql.Append(template.Condition(model, conditions));
            return(sql.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据model信息生成 SELECT [member1],[member2]... FROM [TableName] WHERE [condition1]=@condition,[condition2]=@condition2.....
        /// </summary>
        /// <param name="model">载有生成信息的Model</param>
        /// <param name="condition_models">需要匹配的成员集合</param>
        /// <returns>查询字符串结果</returns>
        public string SelectWithCondition(SqlModel model, params string[] conditions)
        {
            var               select   = Select(model);
            StringBuilder     sql      = new StringBuilder(select);
            ConditionTemplate template = new ConditionTemplate();

            sql.Append(template.Condition(model, conditions));
            return(sql.ToString());
        }