DoNotPerformAddIfPresent=false does nothing

Posts   
 
    
trancehead
User
Posts: 137
Joined: 03-Dec-2007
# Posted on: 18-Mar-2009 11:33:16   

I have a collection.getmulti() call that has a M:N relationship with another table.

Due to the join the generated SQL query returns more than one of the same record. Normally this doesn't matter but in this case I need all the records to be present in the collection.

My code is :


            Me.DoNotPerformAddIfPresent = False
            Dim Filter As IPredicateExpression = New PredicateExpression
            Filter.Add(BookFields.IsActive = True)

            Dim Relations As IRelationCollection = New RelationCollection
            Relations.Add(BookEntity.Relations.BookAwardsEntityUsingBookId)
            Relations.Add(BookAwardsEntity.Relations.AwardEntityUsingAwardId)

            Me.GetMulti(Filter, 0, SortExpression, Relations, PrefetchPath)

The entities are still be left out if the they are present.

I am using the latest build of V2.6 and self servicing.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 18-Mar-2009 13:49:45   

So actually you want to add entities to the collection even if they present in the collection, right?

Does the collection already has entities before the fetch, or you want to prevent the query from using Distinct?

Would you please post the generated Query? Which specific runtime library are you using?

trancehead
User
Posts: 137
Joined: 03-Dec-2007
# Posted on: 18-Mar-2009 14:24:56   

Walaa wrote:

So actually you want to add entities to the collection even if they present in the collection, right?

Yes

Does the collection already has entities before the fetch, or you want to prevent the query from using Distinct?

The collection is empty before the fetch.

Would you please post the generated Query?


Method Exit: CreateSelectDQ
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [LAPA].[dbo].[Book].[ID] AS [Id], [LAPA].[dbo].[Book].[Title], [LAPA].[dbo].[Book].[Abstract], [LAPA].[dbo].[Book].[Extract], [LAPA].[dbo].[Book].[Summary], [LAPA].[dbo].[Book].[CoverArtFilename], [LAPA].[dbo].[Book].[CoverArtThumbnailFilename], [LAPA].[dbo].[Book].[ISBN10] AS [Isbn10], [LAPA].[dbo].[Book].[ISBN13] AS [Isbn13], [LAPA].[dbo].[Book].[NumberOfPages], [LAPA].[dbo].[Book].[PublicationDate], [LAPA].[dbo].[Book].[FormatID] AS [FormatId], [LAPA].[dbo].[Book].[Dimensions], [LAPA].[dbo].[Book].[Keywords], [LAPA].[dbo].[Book].[LapaComment], [LAPA].[dbo].[Book].[isActive] AS [IsActive], [LAPA].[dbo].[Book].[UploadedExtract], [LAPA].[dbo].[Book].[StockNumber] FROM (( [LAPA].[dbo].[Book]  INNER JOIN [LAPA].[dbo].[Book_Awards]  ON  [LAPA].[dbo].[Book].[ID]=[LAPA].[dbo].[Book_Awards].[BookID]) INNER JOIN [LAPA].[dbo].[Award]  ON  [LAPA].[dbo].[Award].[ID]=[LAPA].[dbo].[Book_Awards].[AwardID]) WHERE ( ( [LAPA].[dbo].[Book].[isActive] = @IsActive1)) ORDER BY [LAPA].[dbo].[Award].[Name] ASC
    Parameter: @IsActive1 : Boolean. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: True.

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.

This appears to be right as it brings back multiple records (almost like a left join).

Which specific runtime library are you using?

2.6.9.116

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 18-Mar-2009 16:05:42   

I believe you'll find the answer here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=13408