PrefetchPath suddenly stopped working

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 02-Sep-2015 14:36:33   

Hello,

using LLBGen 4.2 and SQL server, I'm working on a new project (PoC on a legacy database) and had a strange issue today. Last week I generated all entities from a legacy database and started working on a few screens in my poc. But today I deciced i actually don't need all entities, so I opened my LLBgenproj file and removed all entities from it, then re-added the ones I'm interested in, and regenerated the code.

Now suddenly on a exisiting linq query, the WithPath doesn't include one of the entities anymore, and that worked before. Also, if I use SQL Server profiler to look at the generated query, the WithPath prefetchpath is not included in the query. And of course the referenced entity is in the selection of re-generated entities (otherwise it wouldn't even compile)

Any idea ?

EDIT : apparently it's because I'm using twice .WithPath() after each other, and the first WithPath gets "swallowed" . I learned that at the thread : https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=22760&HighLight=1

I followed the advice there, but if I'm using it like this :

var users = metaData.User.WithPath(UserEntity.PrefetchPathAddress, UserEntity.PrefetchPathOrders) 

I'm getting the compiler error :

Error 1 'SD.LLBLGen.Pro.LinqSupportClasses.DataSource2<POC.EntityClasses.UserEntity>' does not contain a definition for 'WithPath' and the best extension method overload 'SD.LLBLGen.Pro.LinqSupportClasses.QueryableExtensionMethods.WithPath<TSource>(System.Linq.IQueryable<TSource>, params SD.LLBLGen.Pro.LinqSupportClasses.IPathEdge[])' has some invalid arguments

Resharper tells me that the first parameters IPrefetchPathelement2 is not assignable to parameter type IPathEdge ..

This is using Linq, not QuerySpec !

EDIT 2 : SOLUTION

instead of

var users = metaData.User.WithPath(UserEntity.PrefetchPathAddress, UserEntity.PrefetchPathOrders) 

use :

var users = metaData.User.WithPath(new PathEdge<AddressEntity>( UserEntity.PrefetchPathAddress), new PathEdge<OrderEntity>(UserEntity.PrefetchPathOrders)) 

and it works !

I have just added it here in case someone else in the future stumbles on the samep problem

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Sep-2015 22:10:55   

Thanks for sharing.