Hi,
I'm using subsonic 2.2 with .net 2.0 and I'm having an error when I included "Group By".
Originally I had this code, and it worked perfectly:
SqlQuery etResourceTitle = new Select(ResTitleOngoing.Columns.ResourceTitleID,
ResTitleOngoing.Columns.ResourceTitle,
VenVendor.Columns.Title,
ResTitleOngoingStatus.Columns.Status).From(Tables.ResTitleOngoing);
etResourceTitle.InnerJoin(ResTitleOngoingStatus.ResourceTitleIDColumn, ResTitleOngoing.ResourceTitleIDColumn);
etResourceTitle.LeftOuterJoin(VenVendor.VendorIDColumn, ResTitleOngoing.VendorIDColumn);
etResourceTitle.OrderAsc(ResTitleOngoing.Columns.ResourceTitle);
etResourceTitle.ExecuteDataSet();
Then I added "Group By", so this is my code:
SqlQuery etResourceTitle = new Select(Aggregate.GroupBy(ResTitleOngoing.Columns.ResourceTitleID),
Aggregate.GroupBy(ResTitleOngoing.Columns.ResourceTitle),
Aggregate.GroupBy(VenVendor.Columns.Title),
Aggregate.GroupBy(ResTitleOngoingStatus.Columns.Status)).From(Tables.ResTitleOngoing);
etResourceTitle.InnerJoin(ResTitleOngoingStatus.ResourceTitleIDColumn, ResTitleOngoing.ResourceTitleIDColumn);
etResourceTitle.LeftOuterJoin(VenVendor.VendorIDColumn, ResTitleOngoing.VendorIDColumn);
etResourceTitle.OrderAsc(ResTitleOngoing.Columns.ResourceTitle);
etResourceTitle.ExecuteDataSet();
I got the error: "Ambiguous column name 'ResourceTitleID'."
Executing etResourceTitle.BuildSqlStatement(); i got:
SELECT ResourceTitleID AS 'GroupByOfResourceTitleID', ResourceTitle AS 'GroupByOfResourceTitle', Title AS 'GroupByOfTitle', Status AS 'GroupByOfStatus' FROM [dbo].[RES_TitleOngoing] INNER JOIN [dbo].[RES_TitleOngoingStatus] ON [dbo].[RES_TitleOngoing].[ResourceTitleID] = [dbo].[RES_TitleOngoingStatus].[ResourceTitleID] LEFT OUTER JOIN [dbo].[VEN_Vendor] ON [dbo].[RES_TitleOngoing].[VendorID] = [dbo].[VEN_Vendor].[VendorID] GROUP BY ResourceTitleID, ResourceTitle, Title, Status ORDER BY ResourceTitle ASC
So, someone can help me with this error.
Thanks Alan