Subsonic Syntax Question (with GroupBy)
Is there a way to do this :
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();
The "GroupBy" part in the last line doesn't compile... (I'm using SubSoni开发者_运维技巧c 2.1)
Just in case there isn't a reason you need the old Where construct:
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>();
With Collections you can use OrderByAsc
and OrderByDesc
but they both only allow passing a string as a parameter. And the SubSonic.AggregateFunction.GroupBy
probably isn't what you want.
Try this instead:
var result = new RegionCollection().OrderByAsc(Region.Columns.RegionName).Load();
精彩评论