internal SqlProjection(string sql, string[] columnAliases, FilterDataType[] type) { _sql = sql; _types = type; _aliases = columnAliases; _columnAliases = columnAliases; }
public EmptySqlFilter(string field, FilterDataType type, object value) : this(null) { SearchItem item = new SearchItem(field, type, value); AppendDefineItems(item); selfDefineSqlFilter = ""; }
public IFilter AppendDefineItems(string Field, FilterDataType dataType, CompareType compareType, object value) { SearchItem item = new SearchItem(Field, dataType, value); item.CompareType = compareType; AppendItems.Add(item); return(this); }
public IFilter AppendDefineItems(string Field, SqlPrefixType prefixType, FilterDataType dataType, CompareType compareType, object beginvalue, object endvalue) { SearchItem item = new SearchItem(Field, dataType, beginvalue); item.SqlPrefixType = prefixType; item.Value2 = endvalue; item.CompareType = compareType; AppendItems.Add(item); return(this); }
public CollectionItemVM(FilterDataType dataType, FilterValue value, bool selected) { DataType = dataType; Id = value.Id; ValueName = !value.ValueName.IsNullOrEmtpy() ? value.ValueName : value.Value; Value = value.Value; Selected = selected; }
public string GetEditValue(object value) { FilterDataType dataType = DataType; if (dataType == FilterDataType.Currency) { dataType = FilterDataType.Decimal; } return(Extensions.GetFormattedValue(value, dataType)); }
internal static string GetFormattedValue(object value, FilterDataType dataType) { if (value == null) { return(null); } else if (dataType == FilterDataType.String) { return(value.ToString()); } string format; switch (dataType) { case FilterDataType.Integer: format = "d"; break; case FilterDataType.Decimal: format = "n2"; break; case FilterDataType.Currency: format = "c2"; break; //case FilterDataType.Percent: // format = "p"; // break; case FilterDataType.Date: format = "d"; break; default: throw new InvalidOperationException("Invalid FilterDataType " + dataType); } string output = string.Format("{0:" + format + "}", value); if ((dataType == FilterDataType.Decimal || dataType == FilterDataType.Currency) && (output.EndsWith(".00") || output.EndsWith(",00"))) { output = output.Substring(0, output.Length - 3); } return(output); }
public static GriddlyFilterRange FilterRange(this GriddlyColumn column, FilterDataType dataType = FilterDataType.Decimal, string field = null, string fieldEnd = null, string caption = null, string htmlClass = null, string captionPlural = null) { if (caption == null) { caption = column.Caption; } if (field == null) { field = GetField(column) + "Start"; } if (fieldEnd == null) { fieldEnd = GetField(column) + "End"; } if (string.IsNullOrWhiteSpace(caption)) { throw new ArgumentNullException("caption", "Caption must be specified."); } if (string.IsNullOrWhiteSpace(field)) { throw new ArgumentNullException("field", "Field must be specified."); } if (string.IsNullOrWhiteSpace(fieldEnd)) { throw new ArgumentNullException("fieldEnd", "End field must be specified."); } var filter = new GriddlyFilterRange() { Field = field, FieldEnd = fieldEnd, Caption = caption, DataType = dataType, HtmlClass = htmlClass }; if (captionPlural != null) { filter.CaptionPlural = captionPlural; } return(filter); }
/// <summary> /// Create sql CASE statement <br/> /// for example<br/> /// <example> /// case<br/> /// when Expression1 then Projection 1 <br/> /// when Expression2 then Projection 2<br/> /// when Expression3 then Projection 3<br/> /// else elseProjection <br/> /// end<br/> /// </example> /// </summary> /// <param name="whenThenExpressions">List of pairs of WhenExpression/ThenProjection's</param> /// <param name="elseProjection">Projection for else</param> /// <param name="alias">Alias of projection</param> /// <param name="filterDataType">Type of result projection</param> /// <returns>Projection</returns> public static AbstractProjection Case(List<KeyValuePair<AbstractExpression, AbstractProjection>> whenThenExpressions, AbstractProjection elseProjection, string alias, FilterDataType filterDataType) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("(case "); foreach (var whenThenExpression in whenThenExpressions) { sb.AppendFormat(" when "); sb.Append(whenThenExpression.Key); sb.AppendFormat(" then "); sb.Append(whenThenExpression.Value); } sb.Append(" else "); sb.Append(elseProjection); sb.Append(" end )"); sb.AppendFormat(" as {0}", alias); string sql = sb.ToString(); return SqlProjection(sql, new[] { alias }, new[] { filterDataType }); }
/// <summary> /// Casts the projection result to the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="projection">The projection.</param> /// <returns></returns> public static AbstractProjection Cast(FilterDataType type, AbstractProjection projection) { return(new CastProjection(type, projection)); }
/// <summary> /// Set the filter data type returning the node providing chainability during configuration /// </summary> /// <param name="node"></param> /// <param name="dataType"></param> /// <returns></returns> public static FilterLeafNode SetDataType(this FilterLeafNode node, FilterDataType dataType) { node.FilterDataType = dataType; return(node); }
/// <summary> /// An SQL projection, that renders properties as if they were added via PropertyProjection /// </summary> /// <param name="formatSql">SQL format string the properties should be put in.</param> /// <param name="properties">The properties.</param> /// <param name="columnAliases">The column aliases.</param> /// <param name="types">The types.</param> /// <returns></returns> public static AbstractProjection SqlFormatProjection(string formatSql, string[] properties, string[] columnAliases, FilterDataType[] types) { return new SQLFormatProjection(formatSql, properties, columnAliases, types); }
/// <summary> /// A SQL projection, a typed select clause fragment /// </summary> /// <param name="sql"></param> /// <param name="columnAliases"></param> /// <param name="type"></param> /// <returns></returns> public static AbstractProjection SqlProjection(string sql, string[] columnAliases, FilterDataType[] type) { return new SqlProjection(sql, columnAliases, type); }
/// <summary> /// Casts the projection result to the specified type. /// </summary> /// <param name="type">The type.</param> /// <param name="projection">The projection.</param> /// <returns></returns> public static AbstractProjection Cast(FilterDataType type, AbstractProjection projection) { return new CastProjection(type, projection); }
/// <summary> /// Create sql CASE statement <br/> /// for example<br/> /// <example> /// case<br/> /// when Expression1 then Projection 1 <br/> /// when Expression2 then Projection 2<br/> /// when Expression3 then Projection 3<br/> /// else elseProjection <br/> /// end<br/> /// </example> /// </summary> /// <param name="whenThenExpressions">List of pairs of WhenExpression/ThenProjection's</param> /// <param name="elseProjection">Projection for else</param> /// <param name="alias">Alias of projection</param> /// <param name="filterDataType">Type of result projection</param> /// <returns>Projection</returns> public static AbstractProjection Case(List <KeyValuePair <AbstractExpression, AbstractProjection> > whenThenExpressions, AbstractProjection elseProjection, string alias, FilterDataType filterDataType) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("(case "); foreach (var whenThenExpression in whenThenExpressions) { sb.AppendFormat(" when "); sb.Append(whenThenExpression.Key); sb.AppendFormat(" then "); sb.Append(whenThenExpression.Value); } sb.Append(" else "); sb.Append(elseProjection); sb.Append(" end )"); sb.AppendFormat(" as {0}", alias); string sql = sb.ToString(); return(SqlProjection(sql, new[] { alias }, new[] { filterDataType })); }
protected CollectionItemVM SetupItem(FilterDataType dataType, FilterValue value, bool selected) { return(new CollectionItemVM(dataType, value, selected)); }
/// <summary> /// 创建指定字段的检索实例(单字段) /// </summary> /// <param name="field"></param> /// <param name="datatype"></param> /// <param name="value"></param> public static SearchItem CreateSearchItem(string field, FilterDataType datatype, CompareType ctype, DateCompareType dtype, object v1, object v2) { return(new SearchItem(field, datatype, ctype, dtype, v1, v2)); }
public static SearchItem CreateSearchItem(string title, FilterDataType datatype, Func <List <DynamicObj> > _getDataSource, Guid QueryID, params SearchFieldInfo[] Fields) { return(new SearchItem(title, datatype, _getDataSource, QueryID, Fields)); }
public static SearchItem CreateSearchItem(string title, FilterDataType datatype, params SearchFieldInfo[] Fields) { return(new SearchItem(title, datatype, Fields)); }
/// <summary> /// Calls the named SQL Function /// </summary> /// <param name="functionName">Name of the function.</param> /// <param name="type">The type.</param> /// <param name="projections">The projections.</param> /// <returns></returns> public static AbstractProjection SqlFunction(string functionName, FilterDataType type, params AbstractProjection [] projections) { return new SqlFunctionProjection(functionName, type, projections); }
/// <summary> /// Determines if the specified member type has selectable values. /// </summary> /// <param name="memberType"> /// The member type. /// </param> /// <returns> /// <c>true</c> if the specified member type has selectable values; otherwise, <c>false</c>. /// </returns> public bool HasSelectableValues(FilterDataType memberType) { switch (memberType) { case FilterDataType.Approval: case FilterDataType.Reference: case FilterDataType.State: return true; } return false; }
/// <summary> /// Returns constant null projection /// </summary> /// <returns></returns> public static AbstractProjection Null(FilterDataType type) { return(SqlProjection("NULL as nullColumn", new[] { "nullColumn" }, new[] { type })); }
/// <summary> /// Calls the named SQL Function /// </summary> /// <param name="functionName">Name of the function.</param> /// <param name="type">The type.</param> /// <param name="projections">The projections.</param> /// <returns></returns> public static AbstractProjection SqlFunction(string functionName, FilterDataType type, params AbstractProjection [] projections) { return(new SqlFunctionProjection(functionName, type, projections)); }
/// <summary> /// 创建多字段的检索实例,这里是同时检索多字段,每个字段过滤条件是以 or 连接 /// </summary> /// <param name="datatype"></param> /// <param name="ctype"></param> /// <param name="dtype"></param> /// <param name="v1"></param> /// <param name="v2"></param> /// <param name="Fields"></param> public static SearchItem CreateSearchItem(FilterDataType datatype, CompareType ctype, DateCompareType dtype, object v1, object v2, SearchFieldInfo[] Fields) { return(new SearchItem(datatype, ctype, dtype, v1, v2, Fields)); }
/// <summary> /// Returns constant null projection /// </summary> /// <returns></returns> public static AbstractProjection Null(FilterDataType type) { return SqlProjection("NULL as nullColumn", new[] {"nullColumn"}, new[] {type}); }
public static SearchItem CreateSearchItem(string field, FilterDataType datatype, object value) { return(new SearchItem(field, datatype, value)); }
/// <summary> /// 创建多字段的检索实例,这里是同时检索多字段,每个字段过滤条件是以 or 连接 /// </summary> /// <param name="datatype"></param> /// <param name="value"></param> /// <param name="Fields"></param> public static SearchItem CreateSearchItem(FilterDataType datatype, object value, SearchFieldInfo[] Fields) { return(new SearchItem(datatype, value, Fields)); }
/// <summary> /// A grouping SQL projection, specifying both select clause and group by clause fragments /// </summary> /// <param name="sql"></param> /// <param name="groupBy"></param> /// <param name="columnAliases"></param> /// <param name="type"></param> /// <returns></returns> public static AbstractProjection SqlGroupProjection(string sql, string groupBy, string[] columnAliases, FilterDataType[] type) { return new SQLGroupProjection(sql, groupBy, columnAliases, type); }