/// <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);
        }
示例#2
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);
        }
示例#3
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(")");
        }
示例#4
0
 /// <summary>
 /// 生成条件值
 /// </summary>
 /// <param name="para">条件值生成接口参数</param>
 protected override void PrimitiveGenerate(ConditionValueGeneratorPara para)
 {
     this.GenerateNull(para.SqlStringBuilder, para.FieldInfo, para.TableAliaName, para.Operater);
 }
示例#5
0
 /// <summary>
 /// 生成条件值
 /// </summary>
 /// <param name="para">条件值生成接口参数</param>
 protected abstract void PrimitiveGenerate(ConditionValueGeneratorPara para);
示例#6
0
 /// <summary>
 /// 生成条件值
 /// </summary>
 /// <param name="para">条件值生成接口参数</param>
 public void Generate(ConditionValueGeneratorPara para)
 {
     this.PrimitiveGenerate(para);
 }