/// <summary>
        /// 生成条件值
        /// </summary>
        /// <param name="para">条件值生成接口参数</param>
        protected override void PrimitiveGenerate(ConditionValueGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count == 0)
            {
                return;
            }

            if (valueList.Count != 1)
            {
                throw new ArgumentException($"字段[{para.FieldInfo.FieldName}]条件值不符合预期,期望一个值");
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(compareOperaterAttribute.OperaterFormat);

            para.SqlStringBuilder.Append(para.ParaSign);
            string parameterName = this.CreateSqlParameterName(para.FieldInfo.FieldName, para.GetParameterIndex());

            para.IncrementParameterIndex();
            para.SqlStringBuilder.Append(parameterName);

            object value = valueList[0];

            if (para.DBFiledValueConverter != null)
            {
                value = para.DBFiledValueConverter.Convert(value);
            }

            para.ParameterNameValueDic.Add(parameterName, value);
        }
        /// <summary>
        /// 生成条件值,无参数
        /// </summary>
        /// <param name="para">无SQL参数条件值生成接口参数</param>
        protected override void PrimitiveGenerateNoPara(ConditionValueNoSqlParaGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count == 0)
            {
                return;
            }

            if (valueList.Count != 1)
            {
                throw new ArgumentException($"字段[{para.FieldInfo.FieldName}]条件值不符合预期,期望一个值");
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(compareOperaterAttribute.OperaterFormat);

            object value = valueList[0];

            if (para.DBFiledValueConverter != null)
            {
                value = para.DBFiledValueConverter.Convert(value);
            }

            string formatValue = para.FieldValueFormator.FieldValueFormat(para.FieldInfo.FieldType, para.FieldInfo.DataType, value);

            para.SqlStringBuilder.Append(formatValue);
        }
예제 #3
0
        /// <summary>
        /// 生成条件值,无参数
        /// </summary>
        /// <param name="para">无SQL参数条件值生成接口参数</param>
        protected override void PrimitiveGenerateNoPara(ConditionValueNoSqlParaGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count != 2)
            {
                throw new ArgumentException($"字段[{para.FieldInfo.FieldName}]条件值不符合预期,期望两个值");
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");
            para.SqlStringBuilder.Append(DBConstant.BLACK_SPACE);

            object value1 = valueList[0];
            object value2 = valueList[1];

            if (para.DBFiledValueConverter != null)
            {
                value1 = para.DBFiledValueConverter.Convert(value1);
                value2 = para.DBFiledValueConverter.Convert(value2);
            }

            string formatValue1 = para.FieldValueFormator.FieldValueFormat(para.FieldInfo.FieldType, para.FieldInfo.DataType, value1);
            string formatValue2 = para.FieldValueFormator.FieldValueFormat(para.FieldInfo.FieldType, para.FieldInfo.DataType, value2);

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(string.Format(compareOperaterAttribute.OperaterFormat, formatValue1, formatValue2));
        }
예제 #4
0
        /// <summary>
        /// 生成条件值
        /// </summary>
        /// <param name="para">条件值生成接口参数</param>
        protected override void PrimitiveGenerate(ConditionValueGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count != 2)
            {
                throw new ArgumentException($"字段[{para.FieldInfo.FieldName}]条件值不符合预期,期望两个值");
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");
            para.SqlStringBuilder.Append(DBConstant.BLACK_SPACE);

            string parameterName1 = this.CreateSqlParameterName(para.FieldInfo.FieldName, para.GetParameterIndex());

            para.IncrementParameterIndex();
            string parameterName2 = this.CreateSqlParameterName(para.FieldInfo.FieldName, para.GetParameterIndex());

            para.IncrementParameterIndex();

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(string.Format(compareOperaterAttribute.OperaterFormat, para.ParaSign + parameterName1, para.ParaSign + parameterName2));

            object value1 = valueList[0];
            object value2 = valueList[1];

            if (para.DBFiledValueConverter != null)
            {
                value1 = para.DBFiledValueConverter.Convert(value1);
                value2 = para.DBFiledValueConverter.Convert(value2);
            }

            para.ParameterNameValueDic.Add(parameterName1, value1);
            para.ParameterNameValueDic.Add(parameterName2, value2);
        }
예제 #5
0
        private void GenerateNull(StringBuilder sbSql, DBFieldInfo dbFieldInfo, string tableAliaName, CompareOperater operater)
        {
            sbSql.Append($"{tableAliaName}.{dbFieldInfo.FieldName}");
            sbSql.Append(DBConstant.BLACK_SPACE);

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(operater);

            sbSql.Append(compareOperaterAttribute.OperaterFormat);
        }
예제 #6
0
        /// <summary>
        /// 生成条件值
        /// </summary>
        /// <param name="para">条件值生成接口参数</param>
        protected override void PrimitiveGenerate(ConditionValueGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count == 0)
            {
                return;
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");
            para.SqlStringBuilder.Append(DBConstant.BLACK_SPACE);

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(compareOperaterAttribute.OperaterFormat);

            para.SqlStringBuilder.Append("(");
            string parameterName;
            int    lastIndex = valueList.Count - 1;
            object value;

            for (int i = 0; i < valueList.Count; i++)
            {
                parameterName = base.CreateSqlParameterName(para.FieldInfo.FieldName, para.GetParameterIndex());
                para.IncrementParameterIndex();
                para.SqlStringBuilder.Append(para.ParaSign);
                para.SqlStringBuilder.Append(parameterName);

                value = valueList[i];
                if (para.DBFiledValueConverter != null)
                {
                    value = para.DBFiledValueConverter.Convert(value);
                }

                para.ParameterNameValueDic.Add(parameterName, value);

                if (i < lastIndex)
                {
                    para.SqlStringBuilder.Append(",");
                }
            }

            para.SqlStringBuilder.Append(")");
        }
예제 #7
0
        /// <summary>
        /// 生成条件值,无参数
        /// </summary>
        /// <param name="para">无SQL参数条件值生成接口参数</param>
        protected override void PrimitiveGenerateNoPara(ConditionValueNoSqlParaGeneratorPara para)
        {
            var valueList = para.ValueList;

            if (valueList == null || valueList.Count == 0)
            {
                return;
            }

            para.SqlStringBuilder.Append($"{para.TableAliaName}.{para.FieldInfo.FieldName}");
            para.SqlStringBuilder.Append(DBConstant.BLACK_SPACE);

            CompareOperaterAttribute compareOperaterAttribute = CompareOperaterHelper.GetCompareOperaterAttributeByCompareOperater(para.Operater);

            para.SqlStringBuilder.Append(compareOperaterAttribute.OperaterFormat);

            para.SqlStringBuilder.Append("(");
            int    lastIndex = valueList.Count - 1;
            object value;
            string formatValue;

            for (int i = 0; i < valueList.Count; i++)
            {
                value = valueList[i];
                if (para.DBFiledValueConverter != null)
                {
                    value = para.DBFiledValueConverter.Convert(value);
                }

                formatValue = para.FieldValueFormator.FieldValueFormat(para.FieldInfo.FieldType, para.FieldInfo.DataType, value);
                para.SqlStringBuilder.Append(formatValue);

                if (i < lastIndex)
                {
                    para.SqlStringBuilder.Append(",");
                }
            }

            para.SqlStringBuilder.Append(")");
        }