public void SetFilterItem(FilterAgent item, FilterLogic logic) { //string columnName = Enum.GetName(typeof(P), this._propertyName); string columnName = this._propertyName; string appendix = ""; if (this._operation == FilterOperation.IsNull || this._operation == FilterOperation.IsNotNull) { appendix = string.Format(" {0} {1} ", columnName, FilterOperationTrans.GetOperationValue(this._operation, this._filterValue)); if (item.FilterString == "") { item.FilterString = appendix; } else { item.FilterString = item.FilterString + System.Enum.GetName(typeof(FilterLogic), logic) + appendix; } return; } if (string.IsNullOrWhiteSpace(this._filterValue)) { return; } string paramName = "P" + GuidGenerator.GetShortGuid(); appendix = string.Format(" {0} {1} {2} ", columnName, FilterOperationTrans.GetOperationByName(this._operation), FilterOperationTrans.GetParamExpression(this._operation, paramName)); item.ParameterNames.Add(DBFactory.ParamSign + paramName); string operationValue = FilterOperationTrans.GetOperationValue(this._operation, this._filterValue); item.ParameterValues.Add(operationValue); if (item.FilterString == "") { item.FilterString = appendix; } else { item.FilterString = item.FilterString + System.Enum.GetName(typeof(FilterLogic), logic) + appendix; } }
protected static void SetFilterItem <T>(FilterAgent item, FilterLogic logic, T dataFilter) where T : IDataItemFilter { string columnName = dataFilter.GetPropertyName(); string appendix = ""; if (dataFilter.Operation == FilterOperation.IsNull || dataFilter.Operation == FilterOperation.IsNotNull) { appendix = string.Format(" {0} {1} ", columnName, FilterOperationTrans.GetOperationValue(dataFilter.Operation, dataFilter.FilterValue)); if (item.FilterString == "") { item.FilterString = appendix; } else { item.FilterString = item.FilterString + System.Enum.GetName(typeof(FilterLogic), logic) + appendix; } return; } if (string.IsNullOrWhiteSpace(dataFilter.FilterValue)) { return; } string paramName = "P" + GuidGenerator.GetShortGuid(); appendix = string.Format(" {0} {1} {2} ", columnName, FilterOperationTrans.GetOperationByName(dataFilter.Operation), FilterOperationTrans.GetParamExpression(dataFilter.Operation, paramName)); item.ParameterNames.Add(DBFactory.ParamSign + paramName); string operationValue = FilterOperationTrans.GetOperationValue(dataFilter.Operation, dataFilter.FilterValue); item.ParameterValues.Add(operationValue); if (item.FilterString == "") { item.FilterString = appendix; } else { item.FilterString = item.FilterString + System.Enum.GetName(typeof(FilterLogic), logic) + appendix; } }