I'm not sure if this is the right place for this, but I am finding that esDataSource doesn't handle Hierarchical Collections too well.
One thing I have found is that if a parent class has a property with the same name as the child you cannot bind or sort without an exception.
For example:
Say you have this data structure:
MasterEntity
------------------
MasterEntityId
Name
ChildEntity
---------------
ChildEntityId
Name
ChildEntityNumber
MasterEntityId
If you perform a search on the ChildEntityNumber like so:
MasterEntityQuery me = new MasterEntityQuery("meq");
MasterEntityCollection mec = new MasterEntityCollection();
ChildEntityQuery ce = new ChildEntityQuery("ceq");
me.InnerJoin(ce).On(me.MasterEntityId == ce.MasterEntityId);
me.Where(ce.ChildEntityNumber == param);
mec.Load(me);
The collection loads fine, but when you bind to the esDataSource and sort it will generate this query:
(FYI, sort is something like this)
this.SearchResultsGV.Sort(MasterEntityMetadata.PropertyNames.Name, SortDirection.Ascending);
exec sp_executesql N'WITH [withStatement] AS (SELECT *, ROW_NUMBER() OVER( ORDER BY [Name] ASC) AS ESRN FROM [MasterEntity] meq INNER JOIN [ChildEntity] ceq ON (meq.[MasterEntityId] = ceq.[MasterEntityId]) WHERE ceq.[ChildEntityNumber] = @ChildEntityNumber1) SELECT * FROM [withStatement] WHERE ESRN BETWEEN 1 AND 2',N'@ChildEntityNumber1 int',@ChildEntityNumber1=12345
Which will generate a SqlException like this:
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Name'.
Msg 8156, Level 16, State 1, Line 1
The column 'Name' was specified multiple times for 'withStatement'.
There are actually two problems here. The Order By does not quality Name to the table, and Name will appear twice in the With statement.
Not sure how easy it is to address these, but thought it might help to have some feedback.