Here is my select
DataTable dt = new DataTable();
IPredicateExpression filter = new PredicateExpression();
//// Create the table we will be returning.
ResultsetFields fields = new ResultsetFields(7);
fields.DefineField(SecurityUsersFieldIndex.FirstName,0, "AssignedByUser", "FromUserName");
fields.DefineField(AppealLocationFieldIndex.AssignedFromUnitCd ,1, "AssignedByUnit");
fields.DefineField(SecurityUsersFieldIndex.LastName,2, "AssignedToUser", "ToUserName");
fields.DefineField(AppealLocationFieldIndex.AssignedToUnitCd, 3, "AssignedToUnit");
fields.DefineField(AppealLocationFieldIndex.FileActionCd, 4, "FileAction");
fields.DefineField(AppealLocationFieldIndex.TransferredDt, 5, "TransferDate");
fields.DefineField(AppealNoteFieldIndex.AppealNoteDesc, 6, "Notes");
// concatenate the name fields
IEntityField[] concatAssignedBy = new IEntityField[] {
EntityFieldFactory.Create(SecurityUsersFieldIndex.FirstName).SetObjectAlias(fields[0].ObjectAlias),
EntityFieldFactory.Create(SecurityUsersFieldIndex.LastName).SetObjectAlias(fields[0].ObjectAlias)};
fields[0].ExpressionToApply = AMS.BLL.Utilities.Queries.GetConcatFieldsExpression(concatAssignedBy, "{0} {1}");
IEntityField[] concatAssignedTo = new IEntityField[] {
EntityFieldFactory.Create(SecurityUsersFieldIndex.FirstName).SetObjectAlias(fields[2].ObjectAlias),
EntityFieldFactory.Create(SecurityUsersFieldIndex.LastName).SetObjectAlias(fields[2].ObjectAlias)};
fields[2].ExpressionToApply = AMS.BLL.Utilities.Queries.GetConcatFieldsExpression(concatAssignedTo, "{0} {1}");
IRelationCollection relationsToUse = new RelationCollection();
relationsToUse.Add(SecurityUsersEntity.Relations.AppealLocationEntityUsingAssignedToUserName, "ToUserName", "", JoinHint.None);
relationsToUse.Add(AppealNoteEntity.Relations.AppealLocationEntityUsingAnAppealLocationId, JoinHint.Right);
filter.Add(PredicateFactory.CompareValue(AMS.DAL.AppealLocationFieldIndex.AppealId, ComparisonOperator.Equal, iAppealId));
ISortExpression sort = new SortExpression();
sort.Add(SortClauseFactory.Create(AMS.DAL.AppealLocationFieldIndex.TransferredDt, SortOperator.Descending));
TypedListDAO dao = new TypedListDAO();
bool b = dao.GetMultiAsDataTable(fields, dt, 100, sort, filter, relationsToUse, true, null, null, 0, 0);
return dt;