private SqlAndParameter GetWhereString() { var re = new SqlAndParameter(); var count = 0; foreach (var where in _whereList) { if (where.Relation == RelationEnum.In) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} IN (@{where.Field.Replace(".", "_")}{count}) "; } else if (where.Relation == RelationEnum.NotIn) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} NOT IN (@{where.Field.Replace(".", "_")}{count}) "; } else if (where.Relation == RelationEnum.IsNotNull || where.Relation == RelationEnum.IsNull) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} {GetDescription(where.Relation)} "; } else if (where.Relation == RelationEnum.Like) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} LIKE '%'+@{where.Field.Replace(".", "_")}{count}+'%' "; } else if (where.Relation == RelationEnum.LeftLike) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} LIKE '%'+@{where.Field.Replace(".", "_")}{count} "; } else if (where.Relation == RelationEnum.RightLike) { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} LIKE @{where.Field.Replace(".", "_")}{count}+'%' "; } else { re.SqlStr += $"{GetDescription(where.Coexist)} {where.Field} {GetDescription(where.Relation)} @{where.Field.Replace(".", "_")}{count} "; } re.Parameter.Add($"@{where.Field.Replace(".", "_")}{count}", where.Value); count++; } foreach (var where in _whereStr) { re.SqlStr += where; } return(re); }
private SqlAndParameter GetUpdateString() { var re = new SqlAndParameter(); var count = 0; foreach (var update in _updateList) { re.SqlStr += $"{update.Key}=@{update.Key}{count},"; re.Parameter.Add($"@{update.Key}{count}", update.Value); count++; } foreach (var update in _updateStr) { re.SqlStr += update + ","; } re.SqlStr = re.SqlStr.TrimEnd(','); return(re); }