public override IParamBuilder GetCondition(IFieldInfo field, string fieldValue) { if (IsEqual) { return(SqlParamBuilder.CreateEqualSql(Context, field, fieldValue)); } else { if (WordSplit) { string[] values = fieldValue.Split(' '); List <IParamBuilder> items = new List <IParamBuilder>(values.Length); int index = 0; foreach (var value in values) { string newValue = value.Trim(); if (!string.IsNullOrEmpty(newValue)) { ++index; IParamBuilder builder = LikeParamBuilder.CreateLikeSql(Context, field, field.FieldName + index, newValue); items.Add(builder); } } return(ParamBuilder.CreateParamBuilder(items)); } else { return(LikeParamBuilder.CreateLikeSql(Context, field, fieldValue)); } } }
public static IParamBuilder CreateLikeSql(TkDbContext context, IFieldInfo fieldName, string paramName, string fieldValue) { LikeParamBuilder builder = new LikeParamBuilder(); return(builder.InternalCreateLikeSql(context, fieldName, paramName, fieldValue)); }
private IParamBuilder CreateItemParamBuilder(string value, bool isEqual, int index = 0) { IParamBuilder[] builders = new IParamBuilder[fFields.Length]; for (int i = 0; i < fFields.Length; ++i) { if (isEqual) { builders[i] = SqlParamBuilder.CreateEqualSql(Context, fFields[i], value); } else { if (index == 0) { builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i], value); } else { builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i], fFields[i].FieldName + index, value); } } } return(SqlParamBuilder.CreateParamBuilderWithOr(builders)); }
private IParamBuilder GetLikeParamBuilder(string value, int index = 0) { return(SqlParamBuilder.CreateParamBuilderWithOr( LikeParamBuilder.CreateLikeSql(Context, fField1, fField1.FieldName + index, value), LikeParamBuilder.CreateLikeSql(Context, fField2, fField2.FieldName + index, value))); }