protected async override Task <JObject[]> ExecuteAsync(AsyncCodeActivityContext context) { var ignoreErrors = IgnoreErrors.Get(context); var collection = Collection.Get(context); var querystring = QueryString.Get(context); var projection = Projection.Get(context); var top = Top.Get(context); var skip = Skip.Get(context); if (top < 1) { top = 100; } if (skip < 0) { skip = 0; } var orderby = Orderby.Get(context); if (string.IsNullOrEmpty(collection)) { collection = "entities"; } JObject[] result = null; result = await global.webSocketClient.Query <JObject>(collection, querystring, projection, top, skip, orderby); System.Windows.Forms.Application.DoEvents(); return(result); }
private MemberBinding ToMemberBinding(Expression it, SelectClause selectClause) { Expression navigationProperty = Expression.MakeMemberAccess(it, _navigationProperty); if (_isCollection) { // NavigationProperty = it.NavigationProperty.Select( arg => new Item { ... } ).ToArray() // NavigationProperty = it.NavigationProperty.Select( arg => new Item { ... } ).ToList() // apply all constraints if (Select != null) { navigationProperty = Select.ApplyTo(navigationProperty); } if (Orderby != null) { navigationProperty = Orderby.ApplyTo(navigationProperty); } if (Filter != null) { navigationProperty = Filter.ApplyTo(navigationProperty); } if (Skip != null) { navigationProperty = Skip.ApplyTo(navigationProperty, ItemType); } if (Top != null) { navigationProperty = Top.ApplyTo(navigationProperty, ItemType); } // build proper select of properties var expression = BuildSelectLambdaExpression(ItemType, selectClause, NestedExpands); navigationProperty = Expression.Call(null, SelectInfo.MakeGenericMethod(ItemType, ItemType), navigationProperty, expression ); // add ToList/ToArray var loadFunction = _navigationProperty.PropertyType.IsArray ? ToArrayInfo.MakeGenericMethod(ItemType) : ToListInfo.MakeGenericMethod(ItemType); navigationProperty = Expression.Call(null, loadFunction, navigationProperty ); } else { // NavigationProperty = new Item { ... } navigationProperty = BuildMemberInit(ItemType, navigationProperty, selectClause, NestedExpands); } return(Expression.Bind(_navigationProperty, navigationProperty)); }
/// <summary> /// 转换排序条件 /// </summary> /// <typeparam name="T">检查字段是否符合条件</typeparam> /// <param name="sortby">排序字段</param> /// <param name="orderby">排序方式</param> /// <param name="prefix">针对SortBy列出来字段的字段前缀,自动会补上点</param> /// <param name="special">特殊情况</param> /// <param name="defaultOrderby">默认排序方式</param> /// <returns></returns> public static string TransformOrderCondition <T>(string sortby, string orderby, string prefix = null, Dictionary <string, string> special = null, Orderby defaultOrderby = Orderby.Desc) { List <string> orderBySql = new List <string>(); string[] fields; string[] orderModes = null; #region + 预处理 if (!string.IsNullOrWhiteSpace(sortby)) { fields = sortby.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } else { //不需要排序 Or ID DESC return(string.Empty); } if (!string.IsNullOrWhiteSpace(orderby)) { orderModes = orderby.Split(','); } if (!string.IsNullOrWhiteSpace(prefix)) { prefix = $"{prefix.TrimEnd('.')}."; } #endregion //如果排序字段不合法,不拼接排序查询sql返回空字符 if (!CheckPropertiesCorrect <T>(special, fields)) { return(string.Empty); } //Sql 拼装 for (var i = 0; i < fields.Length; i++) { Orderby orderMode; if (orderModes == null || orderModes.Length <= i || !Enum.TryParse(orderModes[i], true, out orderMode) || !Enum.IsDefined(typeof(Orderby), orderMode)) { orderMode = defaultOrderby; } if (special != null && special.ContainsKey(fields[i])) { //Special orderBySql.Add(special[fields[i]]); } else { //Properties orderBySql.Add($"{prefix}{fields[i]} {orderMode}"); } } return($" ORDER BY {string.Join(",", orderBySql.ToArray())} "); }
public override System.Collections.Generic.IEnumerable <K> List <K>(AppDto dto, Orderby orderby = null) { if (orderby == null) { orderby = new Orderby(); } var sql = @"SELECT a.[id],a.[od],a.[os],a.[text],a.[tips],a.[keys],a.[file],a.[path],a.[status],a.[update_time],a.[create_time] FROM [cmd_file] a WHERE a.[status] = 1"; return(Query <K>(sql, dto)); }
public void OrderByTestGetOrderDirection() { var isdescending = Orderby.GetOrderDirection("desc"); isdescending = Orderby.GetOrderDirection("1"); isdescending = Orderby.GetOrderDirection("d"); var isAscending = Orderby.GetOrderDirection("asc"); isAscending = Orderby.GetOrderDirection("0"); isAscending = Orderby.GetOrderDirection("a"); }
static void Main(string[] args) { List <string> videoGames = new List <string> { "AngryBirds", "Fortnite", "Pokemon", "Mario" }; Orderby <string> LongVideoGames = videoGames.Where(game => game.Lenth.Contains("5")); foreach (var i in videoGames) { Console.WriteLine(i); } }
/// <summary> /// 参数格式化为列表查询条件对象(解析的节点只包含:Fields、PageIndex、PageSize、Condition、Orderby、Groupby) by hfs 20160909 /// </summary> /// <param name="para"></param> /// <returns></returns> public static ListQuery ToListQuery(this SysParameter para) { XmlDocument orderby = new XmlDocument(); orderby.LoadXml("<Orderby>" + (!string.IsNullOrEmpty(para.ToValue("Orderby")) ? para.ToValue("Orderby") : "") + "</Orderby>"); XmlDocument condition = new XmlDocument(); condition.LoadXml("<Condition>" + (!string.IsNullOrEmpty(para.ToValue("Condition")) ? para.ToValue("Condition") : "") + "</Condition>"); ListQuery query = new ListQuery { Fields = para.ToValue("Fields"), Condition = Condition.Collection(condition), Orderby = Orderby.Collection(orderby), Groupby = para.ToValue("Groupby") }; return(query); }
/// <summary> /// Returns the ranking of value from data array. /// </summary> /// <param name="value">A value for which you want to find the rank</param> /// <param name="orderby">The sorting order of a</param> /// <param name="a">A real numbers array.</param> /// <returns>The rank of value about a.</returns> public static int Rank(double value, Orderby orderby, params double[] a) { Array.Sort(a); for (int i = 0; i < a.Length; i++) { if (a[i] == value) { if (orderby == Orderby.Descending) { return(a.Length - i); } else { return(i + 1); } } } throw new ArgumentOutOfRangeException(); }
/// <summary> /// 参数格式化为分页查询条件对象(解析的节点只包含:Fields、SumFields、PageIndex、PageSize、Condition、Orderby、Groupby) by hfs 20160909 /// </summary> /// <param name="para"></param> /// <returns></returns> public static PagingQuery ToPagingQuery(this SysParameter para) { XmlDocument orderby = new XmlDocument(); orderby.LoadXml("<Orderby>" + (!string.IsNullOrEmpty(para.ToValue("Orderby")) ? para.ToValue("Orderby") : "") + "</Orderby>"); XmlDocument condition = new XmlDocument(); condition.LoadXml("<Condition>" + (!string.IsNullOrEmpty(para.ToValue("Condition")) ? para.ToValue("Condition") : "") + "</Condition>"); PagingQuery query = new PagingQuery { Fields = para.ToValue("Fields"), SumFields = para.ToValue("SumFields"), PageIndex = para.ToInt("PageIndex", 1), PageSize = para.ToInt("PageSize", 10), Condition = Condition.Collection(condition), Orderby = Orderby.Collection(orderby), Groupby = para.ToValue("Groupby") }; return(query); }
public async Task <ParsedJsonPopulation> CercaAsync(string Text, List <TerritorialEntity> TerritorialEntities, List <Similarity> Similarities, Selector selector, Orderby orderby, int position) { var param = new Parameters(); param.Add("q", Text); param.Add("tipus", TerritorialEntities); param.Add("sim", Similarities); param.Add("selec", selector); param.Add("orderby", orderby); param.Add("posicio", position.ToString()); var request = new HttpRequestMessage(HttpMethod.Get, Identifier + "cerca.json" + "?" + param.ToString()); var response = await _httpClient.SendAsync(request); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); //buscar entry i posar un [] si fa falta int startPos = content.IndexOf("entry"); startPos += 7; // the json is not well made and changes depending if there is only one entry or several // so, we fix it by changing to json to the same format in case there is only one entry if (content[startPos] != '[') { // we add [ and ] at the beginning and at the end of the entry section content = content.Insert(startPos, "["); // search end position int endPos = content.IndexOf("\"xmlns\"") - 1; content = content.Insert(endPos, "]"); } return(ParsedJsonPopulation.FromJson(content)); } else { throw new HttpRequestException($"The request was responded with an HTTP Code: {response.StatusCode}"); } }
/// <summary> /// Sort Alphanumeric as Alphanumeric and numeric as numeric /// </summary> /// <param name="isDescending">Is the order direction descending</param> public NaturalSortComparer(bool isDescending) { _orderDirection = Orderby.GetOrderDirection(isDescending); }
public override int GetHashCode() { return(ViewMode.GetHashCode() + ImageViewMode.GetHashCode() + Id.GetHashCode() + (!String.IsNullOrEmpty(Name) ? Name.GetHashCode() : 0) + Sortby.GetHashCode() + Orderby.GetHashCode()); }
public override int GetHashCode() { return(ViewMode.GetHashCode() + (ID.HasValue ? ID.Value.GetHashCode() : 0) + ImageViewMode.GetHashCode() + (Event_ID.HasValue ? Event_ID.Value.GetHashCode() : 0) + (!String.IsNullOrEmpty(Lot) ? Lot.GetHashCode() : 0) + ShortFilterString().GetHashCode() + ShortSimpleFilterString().GetHashCode() + Sortby.GetHashCode() + Orderby.GetHashCode()); }
private ISortClauseBuilder <TKey, TEntity> Sort(Expression <Func <TEntity, object> > member, Orderby orderby) { if (member == null) { throw new ArgumentNullException(nameof(member)); } var mn = $"{_storeMapping.GetEscapeTableName(_classMap.TableName, _dialectSettings)}{_storeMapping.GetEscapeColumnName(_classMap.Properties.Get(member.GetMemberName()).ColumnName, _dialectSettings)}"; _body.Insert(mn, orderby); return(this); }
public override int GetHashCode() { return(Id.GetHashCode() + Sortby.GetHashCode() + Orderby.GetHashCode() + ViewMode.GetHashCode() + page.GetHashCode() + PageSize.GetHashCode()); }