Yeah sorry 2.0.Using C# and ASP.NET 2.0.
Ok that did'n work..here is the code with the problems:
One method that returns the list for an ObjectDataSource in which we have :
SME_SupplierOrganisationTypedList ret = new SME_SupplierOrganisationTypedList();
ret.Columns.Add("PrimaryContact", typeof(string), "LastName + ', ' + FirstName");
IRelationPredicateBucket bucket = CreateBucketForSMESupplierOrganisationListTypedList(parameters, orgUnitId);
ISortExpression sorter = CreateSorterForSMESupplierOrganisationListTypedList(sortField);
int pageNumber = LlblHelper.GetPageNumber(rowIndex, pageSize);
using (DataAccessAdapter dataAdapter = DataAdapterFactory.NewDataAdapter())
{
dataAdapter.FetchTypedList(ret.GetFieldsInfo(), ret, bucket, 0, sorter, false, null, pageNumber, pageSize);
}
and the CreateBucket method creates the filetring data in wich all the expressions are added like
ret.PredicateExpression.Add(new FieldCompareValuePredicate(CORE_SupplierOrganisationFields.IsDeleted, null, ComparisonOperator.Equal, 0, "SO"));
as you can see the aliases for the tables in the TypedList are specified.
And the sorter method
public static ISortExpression CreateSorterForSMESupplierOrganisationListTypedList(string sortField)
{
if (string.IsNullOrEmpty(sortField))
sortField = "Name";
SortOperator operatorToUse = LlblHelper.GetSortType(sortField);
sortField = sortField.Split(' ')[0];
ISortExpression sorter = new SortExpression();
switch (sortField)
{
case "PrimaryContact": //full name of the supplier
sorter.Add(UME_CustomerFields.LastName | operatorToUse);
sorter.Add(UME_CustomerFields.FirstName | operatorToUse);
break;
case "Name": // SO name
sorter.Add(CORE_SupplierOrganisationFields.Name.SetObjectAlias("SOPCC") | operatorToUse);
break;
case "DUNS":
sorter.Add(CORE_SupplierOrganisationFields.DUNS | operatorToUse);
break;
case "CreatedOn":
sorter.Add(CORE_SupplierOrganisationFields.CreatedOn | operatorToUse);
break;
default:
throw new NotImplementedException();
}
return sorter;
}
it is currently called to enter the Name case (modified according to you). With the profiler I get after dataAdapter.FetchTyedList() call the following:
SELECT [LPA_S1].[SupplierOrganisationID],
[LPA_S1].[OrgUnitID], [LPA_S1].[Name],
[LPA_S1].[DUNS], [LPA_S6].[CustomerID] AS [PrimaryContactID],
[LPA_S6].[FirstName], [LPA_S6].[LastName],
[LPA_S1].[CreatedOn]
FROM (((((((( [dbo].[tbl_CORE_SupplierOrganisation] [LPA_S1]
INNER JOIN [dbo].[tbl_CORE_AddressBookXSupplierOrganisation] [LPA_A2] ON [LPA_S1].[SupplierOrganisationID]=[LPA_A2].[SupplierOrganisationID])
INNER JOIN [dbo].[tbl_AddressBooks] [LPA_A3] ON [LPA_A3].[AddressBookID]=[LPA_A2].[AddressBookID])
INNER JOIN [dbo].[tbl_OrgUnitAddressBook] [LPA_O4] ON [LPA_A3].[AddressBookID]=[LPA_O4].[AddressBookID])
LEFT JOIN [dbo].[tbl_CORE_SupplierOrganisationXCustomer] [LPA_S5] ON [LPA_S1].[SupplierOrganisationID]=[LPA_S5].[SupplierOrganisationID])
LEFT JOIN [dbo].[tbl_Customer] [LPA_S6] ON [LPA_S6].[CustomerID]=[LPA_S5].[CustomerID])
LEFT JOIN [dbo].[tbl_REG_CustomerRegistration] [LPA_C7] ON [LPA_S6].[CustomerID]=[LPA_C7].[CustomerID])
INNER JOIN [dbo].[tbl_CORE_SupplierOrganisationXCustomer] [LPA_S8] ON [LPA_S1].[SupplierOrganisationID]=[LPA_S8].[SupplierOrganisationID])
INNER JOIN [dbo].[tbl_Customer] [LPA_C9] ON [LPA_C9].[CustomerID]=[LPA_S8].[CustomerID])
WHERE ( ( [LPA_S1].[IsDeleted] = 0 AND [LPA_O4].[OrgUnitID] = 1680
AND [LPA_S6].[Status] NOT IN (-1, -2, -5)
AND [LPA_S5].[IsPrimaryContact] = 1
AND [LPA_C9].[Status] NOT IN (-1, -2, -5)
AND ( [LPA_C9].[isActive] = 1
OR ( [LPA_C9].[isActive] = 0
AND [LPA_C7].[IsRegistrationComplete] = 0))))
ORDER BY [SOPCC].[Name] ASC