Hi,
I noticed what seems to be an issue with your esDataSource AutoPaging yesterday. I wondered if you could confirm if it is a bug or not. Basically, In the DataSource's esSelect event handler, I set the DataSource's query with
Code:
protected void coursesDataSource_esSelect(object sender, esDataSourceSelectEventArgs e)
{
e.Collection = new CourseCollection();
e.Query = GetSearchQuery();
}
Initially, GetSearchQuery() ran a select on just one table
Code:
private CourseQuery GetSearchQuery()
{
CourseQuery course = new CourseQuery("course");
course.Select(
course.CourseId,
course.Date.As("CourseDate"),
course.CustomerId.As("CustomerName"),
course.ProductCode.As("ProductName"),
course.AddressPostCode.As("Location"),
course.ExpectedNumberOfDelegates.As("ExpectedDelegates"),
course.Cost.As("ConfirmedDelegates"),
course.StatusId.As("Status"));
return course;
}
But when bound into the GridView, ASP.NET returned a lot of errors saying that many multiple.valued identifiers could not be bound to the GridView. Doing a quick check, this was because ES was generating the follwoing invalid command
Code:
WITH [withStatement] AS
(SELECT course.[CourseId],
course.[Date] AS 'CourseDate',
course.[CustomerId] AS 'CustomerName',
course.[ProductCode] AS 'ProductName',
course.[AddressPostCode] AS 'Location',
course.[ExpectedNumberOfDelegates] AS 'ExpectedDelegates',
course.[Cost] AS 'ConfirmedDelegates',
course.[StatusId] AS 'Status' ,
ROW_NUMBER() OVER( ORDER BY course.Date ASC) AS ESRN
FROM [Course] course)
SELECT course.[CourseId],
course.[Date] AS 'CourseDate',
course.[CustomerId] AS 'CustomerName',
course.[ProductCode] AS 'ProductName',
course.[AddressPostCode] AS 'Location',
course.[ExpectedNumberOfDelegates] AS 'ExpectedDelegates',
course.[Cost] AS 'ConfirmedDelegates',
course.[StatusId] AS 'Status'
FROM [withStatement] WHERE ESRN BETWEEN 1 AND 15
However, if I added the first of (many) joins to the search query like so
Code:
private CourseQuery GetSearchQuery()
{
CourseQuery course = new CourseQuery("course");
UserCustomerQuery customer = new UserCustomerQuery("customer");
course.Select(
course.CourseId,
course.Date.As("CourseDate"),
customer.Name.As("CustomerName"),
course.ProductCode.As("ProductName"),
course.AddressPostCode.As("Location"),
course.ExpectedNumberOfDelegates.As("ExpectedDelegates"),
course.Cost.As("ConfirmedDelegates"),
course.StatusId.As("Status"));
course.InnerJoin(customer).On(course.CustomerId == customer.UserId);
return course;
}
Then all the binding works fine and the GridView is populated correctly. And the SQL that ES generates looks like this
Code:
WITH [withStatement] AS
(SELECT course.[CourseId],
course.[Date] AS 'CourseDate',
customer.[Name] AS 'CustomerName',
course.[ProductCode] AS 'ProductName',
course.[AddressPostCode] AS 'Location',
course.[ExpectedNumberOfDelegates] AS 'ExpectedDelegates',
course.[Cost] AS 'ConfirmedDelegates',
course.[StatusId] AS 'Status' ,
ROW_NUMBER() OVER( ORDER BY course.Date ASC) AS ESRN
FROM [Course] course
INNER JOIN [UserCustomer] customer ON course.[CustomerId] = customer.[UserId])
SELECT * FROM [withStatement] WHERE ESRN BETWEEN 1 AND 15
Which is pretty different from the first SQL generated without the join. The first SQL statement definitely doesn't work. Thought you should know.