开发者

Orderby on an Iesi set

开发者 https://www.devze.com 2023-01-15 01:23 出处:网络
Is there any way to perform a Linq OrderBy on a column in an OrderedSet (Iesi.Collection) and get the output as an ordered set. There appears to be no way to convert between IOrderedEnumerable and ISe

Is there any way to perform a Linq OrderBy on a column in an OrderedSet (Iesi.Collection) and get the output as an ordered set. There appears to be no way to convert between IOrderedEnumerable and ISet...

开发者_StackOverflow社区

Thanks


If you want to convert it after the query:

IOrderedEnumerable<int> x = ...
OrderedSet<int> s = new OrderedSet<int>(x.ToArray());

Or wrap it in an extension method for convenience:

public static class EnumerableExtensions {
  public static OrderedSet<T> ToOrderedSet<T>(this IEnumerable<T> s) {
    return new OrderedSet<T>(s.ToArray());
  }
}

IOrderedEnumerable<int> x = ...
OrderedSet<int> s = x.ToOrderedSet();
0

精彩评论

暂无评论...
验证码 换一张
取 消