Hi there,
I'm having a problem with converting
" SELECT [dbo].[PageVersions].[pageId], [dbo].[PageVersions].[pageVersionId], [dbo].[PageVersions].[pageName]
FROM [dbo].[PageVersions]
INNER JOIN [dbo].[Pages] ON [dbo].[PageVersions].[pageId] = [dbo].[Pages].[pageId]
WHERE parentPageId IS NULL
AND [dbo].[PageVersions].[pageVersionId] IN(
SELECT Max([dbo].[PageVersions].[pageVersionId]) FROM [dbo].[PageVersions]
GROUP BY [dbo].[PageVersions].[pageId])"
into SubSonic select query.
As you can see, my INNER SELECT must return only one column to be used in outer SELECT, but when I add GROUP BY aggregate it also apears between SELECT ... FROM text.
"Only one expression can be specified in the select list when the subquery is not introduced with EXISTS."
But that's the second issue, firstly I have encountered the following issue.
"You must specify a column to return for the IN to be valid. Use Select("column") to do this"
In
public SqlQuery In(Select selectQuery)
{
//validate that there is only one column in the columnlist
if(selectQuery.SelectColumnList.Length == 0 || selectQuery.SelectColumnList.Length > 1)
throw new SqlQueryException("You must specify a column to return for the IN to be valid. Use Select(\"column\") to do this");
you check for SelectColumnList.Length, but it returns 0 when the only column to return is aggregate as in my case.
I've tried this way
Select ss = new Select("maxId");
ss.Aggregates.Add(Aggregate.Max(DAL.PageVersion.PageVersionIDColumn, "maxId"));
ss.Aggregates.Add(Aggregate.GroupBy(DAL.PageVersion.PageIdColumn));
ss.From(DAL.PageVersion.Schema);
but now I have 3 columns to be returned and I cannot use in IN clause.
Any suggestions ? Thanks.