Inheritance Hierarchy Fix

Posts   
 
    
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 07-Mar-2008 10:06:59   

Hi,

I tried searching for other posts but could not find any on this topic.

25-jan-2008: (Runtime Libraries, 2.5.01252008 ): * FIX : Small change on join hint for hierarchy relations added to list fetch of fields in inheritance hierarchy: relations are now added as left joins instead of inner joins.

Could you please explain why this has been changed as I cannot understand when it would ever be used like this.

For example, if you have a User that is a Sub-Type of Person, you create a UserTypedList (that only contains the User table) and select some User fields (Username and Passowrd) and Person fields (FirstName and LastName) and then .Fill() the UserTypedList.

You are not going to get the correct result set... You going to get all the Users and also all the Persons that are not in the User table.

Is there a setting that we can use to force it to use INNER JOIN and not a LEFT JOIN?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Mar-2008 10:51:15   

We had to fix this due to a problem with finding inheritance relations. INNER joins could result in edge cases in 0 rows returned.

The thing however was: we did think this through and we couldn't find an edge case which caused this to fail. The problem was however that there was another bug we didn't encounter for, which was fixed on feb 28: type filters have to be added and that wasn't always the case, so using a left join without type filters would cause problems and we discovered this when writing a unit test to test some other edge case which showed up the problem you describe.

So please download the latest build of the runtime lib and try again. Sorry for this inconvenience.

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 07-Mar-2008 10:53:49   

Hi Otis,

Ok cool will give them a bash.

Thanks very much.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Mar-2008 11:01:32   

We ran into the issue during linq development where INNER joins made the list result as 0 while it should have fields. This was the case when there were 2 inheritance paths in the list of fields.

Please let me know if the latest runtime doesn't fix your issue. If it doesn't please describe your inheritance hierarchy, query etc. so we can setup a testcase here and check what to do about it. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 07-Mar-2008 11:09:42   

Hi Otis,

It seems to be working perfectly, Thanks.

I must have downloaded the old version like a day before it this one was put up. Sorry I should have checked for a newer version before posting.

On a side note, a few colleagues and I are very excited about the LINQ to LLBLGen layer we have seen on your blob.

wink To be honest I haven't had the time to read all the articles properly but I will get around to it soon. A few public holidays coming up in two weeks here is South Africa.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Mar-2008 11:22:04   

deathwish wrote:

Hi Otis,

It seems to be working perfectly, Thanks.

great! simple_smile

I must have downloaded the old version like a day before it this one was put up. Sorry I should have checked for a newer version before posting.

On a side note, a few colleagues and I are very excited about the LINQ to LLBLGen layer we have seen on your blob.

wink To be honest I haven't had the time to read all the articles properly but I will get around to it soon. A few public holidays coming up in two weeks here is South Africa.

simple_smile I'm wrapping up the final elements now. Hierarchical fetches are done for 95%, and now some small things have to be added, like support for full text search, excluded fields specifications, specifying a context, but these are pretty minor as they don't affect the expression tree stuff. We hope to have the Linq CTP code ready early next week (though I think wednesday or so) and you all can start hammering out linq queries to see if it works out ok or not simple_smile

I was sceptical about linq at first, but it has some nice features overall, like specifying queries in a very compact form. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
deathwish
User
Posts: 56
Joined: 07-Nov-2006
# Posted on: 11-Mar-2008 11:18:00   

Hey,

I just found a tiny bug and wondered if you had a remedy for it.

I am using SQL Server 2005, .Net 3.5 and latest LLBLGen release ( 2.5.8.228 ).

We have a Result table that has a FK UserId (to the User table of course) which allows nulls. User is a sub-type of Person due to the 1-to-1 relationship in the database. The UserId in the Result table will only have a value when the result has been validated.

So now when I try to execute the following code (which is a scaled down version of the real thing wink ):


ResultsetFields fields = new ResultsetFields(3);
fields[0] = ResultFields.Result;
fields[1] = UserFields.FirstName;
fields[2] = UserFields.LastName;

RelationCollection collection = new RelationCollection(ResultEntity.Relations.AnalyseEntityUsingAnalyseId);
collection.Add(ResultEntity.Relations.UserEntityUsingUserId, JoinHint.Left);

DataTable table = DynamicList.GetTypedListDataTable(fields, null,
    new PredicateExpression(AnalyseFields.RequestId == new Guid("8F605773-4CEF-DC11-B310-0003FF1774A2")),
    collection, false);

The following SQL is fired off against the database:


exec sp_executesql N'SELECT DISTINCT [preLink].[dbo].[Result].[Result], [LPA_L1].[FirstName], [LPA_L1].[LastName] FROM ((( [preLink].[dbo].[Analyse]  INNER JOIN [preLink].[dbo].[Result]  ON  [preLink].[dbo].[Analyse].[AnalyseId]=[preLink].[dbo].[Result].[AnalyseId]) LEFT JOIN [preLink].[dbo].[User] [LPA_L2]  ON  [LPA_L2].[UserId]=[preLink].[dbo].[Result].[UserId]) LEFT JOIN [preLink].[dbo].[Person] [LPA_L1]  ON  [LPA_L1].[PersonId]=[LPA_L2].[UserId]) WHERE ( ( [preLink].[dbo].[Analyse].[RequestId] = @RequestId1) AND ( ( [LPA_L2].[UserId] IS NOT NULL)))',N'@RequestId1 uniqueidentifier',@RequestId1='8F605773-4CEF-DC11-B310-0003FF1774A2'

Which will only return records from the Results table where the UserId is not null. cry I need to be able to view ones that do not have a UserId as well.

Is there a way to turn off "AND ( ( [LPA_L2].[UserId] IS NOT NULL))"?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 13-Mar-2008 11:21:20   

It's a typefilter as you've specified that you wanted to have user fields. Say you have another subtype of Person. If the typefilter isnt' there, you could also get fields returned from those rows, and this way it eliminates these.

I think you can work around it by adding a predicate with OR which tests for ResultFields.USerId being null. So it basicly adds: (OR [preLink].[dbo].[Result].[UserId] IS NULL)

Frans Bouma | Lead developer LLBLGen Pro