private string FormatAttribute(string formatString) { var buttonClick = formatString; if (!DataFields.IsNullOrEmpty()) { var dataFields = DataFields.Split(','); object[] param = new object[dataFields.Length]; for (int i = 0; i < dataFields.Length; i++) { param[i] = RowData[dataFields[i]]; } buttonClick = string.Format(CultureInfo.CurrentCulture, buttonClick, param); } return(buttonClick); }
public override IQueryable GetQueryable(IQueryable source) { if (source == null) { return(null); } if ((DataFields == null) || String.IsNullOrEmpty(DataFields.Trim())) { throw new InvalidOperationException(AtlasWeb.Expressions_DataFieldRequired); } IDictionary <string, object> values = GetValues(); if (values.Count == 0) { throw new InvalidOperationException(AtlasWeb.SearchExpression_ParameterRequired); } string query = Convert.ToString(values.First().Value, CultureInfo.CurrentCulture); if (String.IsNullOrEmpty(query)) { return(null); } string[] properties = DataFields.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); // Use the or expression to or the fields together List <Expression> searchExpressions = new List <Expression>(); ParameterExpression parameterExpression = Expression.Parameter(source.ElementType, String.Empty); foreach (string p in properties) { Expression property = ExpressionHelper.CreatePropertyExpression(parameterExpression, p.Trim()); searchExpressions.Add(CreateCallExpression(property, query)); } return(ExpressionHelper.Where(source, Expression.Lambda(ExpressionHelper.Or(searchExpressions), parameterExpression))); }