代码之家  ›  专栏  ›  技术社区  ›  mrmuggles

亚音速句法问题(带groupby)

  •  0
  • mrmuggles  · 技术社区  · 15 年前

    有没有办法做到这一点:

    SubSonic.Where filter = new SubSonic.Where();
    filter.ColumnName = Region.Columns.Region;
    filter.Comparison = SubSonic.Comparison.IsNot;
    filter.ParameterValue = null;
    
    SubSonic.Aggregate orderBy = new SubSonic.Aggregate(Region.Columns.RegionName, SubSonic.AggregateFunction.GroupBy);
    
    RegionCollection regions = new RegionCollection().Where(filter).GroupBy(groupBy).Load();
    

    最后一行中的“groupby”部分无法编译…(我用的是亚音速2.1)

    2 回复  |  直到 14 年前
        1
  •  0
  •   Dave Neeley    14 年前

    以防您不需要旧的where结构:

    SubSonic.Aggregate groupBy = new SubSonic.Aggregate(Region.Columns.RegionName, SubSonic.AggregateFunction.GroupBy);
    
    RegionCollection regions = new SubSonic.Select(groupBy).From(Region.Schema).Where(Region.RegionColumn).IsNotNull().ExecuteAsCollection<RegionCollection>();
    
        2
  •  0
  •   Jürgen Steinblock    15 年前

    对于集合,您可以使用 OrderByAsc OrderByDesc 但它们都只允许将字符串作为参数传递。以及 SubSonic.AggregateFunction.GroupBy 可能不是你想要的。

    试试这个:

    var result = new RegionCollection().OrderByAsc(Region.Columns.RegionName).Load();
    
    推荐文章