Weird Alias Problem

Posts   
 
    
rvanv
User
Posts: 6
Joined: 15-Sep-2005
# Posted on: 26-Oct-2005 20:50:33   

I have a strange problem (at least to me) that I haven't been able to find the answer to. Using the new LLBLGen Pro 1.0.2005.1 (I love this product), I have a defined a supertype (Parties table) and several sub-type entities.

When the PartiesCollection SQL executes it places sequentially incremented values ([F0], [F1], [F2], etc) as the alias. This is causing a real headache when the band on my win grid needs to have identical column names for the parent/child relationship. Here is the code that I'm executing:

 Dim myColl As New MDC.Data.CollectionClasses.PartiesCollection
myColl.GetMulti(predicate)

This is the SQL code that's executed (notice the alias's):

 SELECT DISTINCT TOP 1 [dbo].[tblParties].[PartyID] AS [F0], [dbo].[tblParties].[LoanID] AS [F1], [dbo].[tblParties].[FriendlyName] AS [F2]...

This only happens on inherited entities. Any ideas how I can change the alias?

Thanks...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Oct-2005 22:36:08   

These aliases are by design, as teh fields are for several entities in a hierarchy.

Could you explain to me what the real problem is with these aliases? As they're picked up by teh fetch logic and transfered back to values per entity (it knows per alias which entity it belongs to in the hierarchy), so the entity fields have the right values. I don't see how these aliases could end up in a grid simple_smile

Frans Bouma | Lead developer LLBLGen Pro
rvanv
User
Posts: 6
Joined: 15-Sep-2005
# Posted on: 26-Oct-2005 23:30:25   

Otis wrote:

I don't see how these aliases could end up in a grid simple_smile

Your right. These fields are not showing in the grid. I only saw these fields via the SQL profiler. I only came to this conclusion since the data from one of the superclasses was not displaying in the grid (I'm using the latest WinGrid from Infragistics). This seemed like the common denominator since I'm executing other queries without incident.

Let me give you some additional information. I'm working with three tables: Parties (PartyID), xrfPartiesCollateral (PartyID, CollateralID), and Collateral (CollateralID). The only results that are displayed in the grid is the Party and the PartyCollateral cross-ref table. The actual Collateral for the party is not present. I'm clueless as to how to get this data to display. If you wouldn't mind, would you review the following code. I think that it's right, but can always use lots of pointers.

 Dim borrowers As New MDC.Data.CollectionClasses.PartiesCollection

            Dim predicate As IPredicateExpression = New PredicateExpression
            predicate.Add(PredicateFactory.CompareValue(MDC.Data.PartiesFieldIndex.IsDeleted, ComparisonOperator.Equal, False))
            predicate.AddWithAnd(PredicateFactory.CompareValue(MDC.Data.PartiesFieldIndex.IsBorrower, ComparisonOperator.Equal, True))

            Dim sortOrder As ISortExpression = New SortExpression
            sortOrder.Add(SortClauseFactory.Create(MDC.Data.PartiesFieldIndex.FriendlyName, SortOperator.Ascending))

            Dim relations As IRelationCollection = New RelationCollection()
            relations.Add(MDC.Data.EntityClasses.PartiesEntity.Relations.CollateralsLoanPartiesEntityUsingPartyId)
            relations.Add(MDC.Data.EntityClasses.CollateralsLoanPartiesEntity.Relations.CollateralsEntityUsingCollateralId)
            relations.Add(MDC.Data.EntityClasses.CollateralsEntity.Relations.CollateralsLoanPartiesEntityUsingCollateralId)
            relations.Add(MDC.Data.EntityClasses.CollateralsEntity.Relations.PartialReleasesEntityUsingCollateralId, JoinHint.Left)

            Dim prefetchPath As IPrefetchPath = New PrefetchPath(CType(MDC.Data.EntityType.PartiesEntity, Integer))
            prefetchPath.Add(MDC.Data.EntityClasses.PartiesEntity.PrefetchPathCollateralsLoanParties).SubPath.Add( MDC.Data.EntityClasses.CollateralsLoanPartiesEntity.PrefetchPathCollaterals).SubPath.Add( MDC.Data.EntityClasses.CollateralsEntity.PrefetchPathPartialReleases)

            borrowers.GetMulti(predicate, 0, sortOrder, relations, prefetchPath)

Thanks again. BTW: Great app!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Oct-2005 15:00:40   

Ah simple_smile

Say you have a hierarchy like this: A <- B <- C A <- D

A collection of type A is fetched, which thus can contain entities of type A, B, C and D. A defines fields F1 and F2. B defines extra fields F3 and F4. C defines extra field F5 and D defines extra field F6.

A grid works with columns which represent a property in EVERY element in the bound collection. However this leads to a problem: which columns to display? You bind a collection of type 'A', so all elements have the types F1 and F2.

What to do with the other fields? Some elements in the collection have fields F1-F4, others have F1, F2 and F5, others have F1, F2 ad F6 etc.

Displaying all columns next to eachother looks like a solution but this has the disadvantage that the user looking at the rows doesn't understand which column belongs to which TYPE.

i.o.w.: unsolveable, so only the columns of the type of the collection are shown, Parties. (or A in my example).

(btw, you can add #imports MDC.Data etc. at the top of your code file so you don't have to type all the namespace names each time wink )

Frans Bouma | Lead developer LLBLGen Pro