public SqlWhere( string[] columnBrackets = null, string tableName = null, string name = null, object value = null, string _operator = "=", string multiColumnOperator = " or ", string multiParamOperator = " and ", SqlStatement subLeft = null, SqlStatement sub = null, string raw = null, SqlWhereCollection or = null, bool _using = true) { ColumnBrackets = columnBrackets; TableName = tableName; Name = name; Value = value; Operator = _operator; MultiColumnOperator = multiColumnOperator; MultiParamOperator = multiParamOperator; SubLeft = subLeft; Sub = sub; Raw = raw; Or = or; Using = _using; Or?.Where(o => o != null).ForEach(o => o.Name += "_or"); }
private void AddParams_Where( SqlCommand sqlCommand, SqlWhereCollection sqlWhereCollection, int?commandCount) { sqlWhereCollection? .Where(o => o != null) .Where(o => o.Using) .ForEach(sqlWhere => { if (sqlWhere.Value != null) { if (sqlWhere.Value.IsCollection()) { (sqlWhere.Value.ToObjectEnumerable()) .Select((o, i) => new { Value = o, Index = i }) .ForEach(data => AddParam( sqlCommand, sqlWhere.Name + data.Index + "_", data.Value, commandCount)); } else { AddParam( sqlCommand, sqlWhere.Name, sqlWhere.Value, commandCount); } } AddParams_Where(sqlCommand, sqlWhere.Or, commandCount); }); }