PreFetch on Linq query

Posts   
 
    
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 15-Jan-2018 06:31:06   

Using an Adapter and following the doco example, what am I doing wrong in the attached expression?


            var qf = new QueryFactory();
            var q = db.UserStream
                    .Where(u => (!u.Processed))
                    .WithPath(UserStreamEntity.PrefetchPathStreamrow.WithSubPath(StreamrowEntity.PrefetchPathStream))

Attachments
Filename File size Added on Approval
llblgen_Capture.PNG 35,617 15-Jan-2018 06:31.39 Approved
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 15-Jan-2018 08:16:02   

Well the following format works, but is different to the example in the doco:


    var q = db.UserStream
        .WithPath(p => p.Prefetch<StreamrowEntity>(x => x.Streamrow).SubPath(op => op.Prefetch<StreamEntity>(sr => sr.Stream)))
        .Where(u => (!u.Processed))
        .Where(u => u.Streamrow.Stream.ProjectId == _scriptUserContext.ProjectContext.ProjectId
                            && (u.Streamrow.Stream.Name == filter || filter == null));

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Jan-2018 08:17:12   

In the picture, What is variable db of type Database? Why you didn't use qf?

var q = qf.UserStream
...

Are you using Linq or QuerySpec for fetching the query?

What is the LLBLGen version and runtime library version that you are using? ( http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725 )

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 15-Jan-2018 10:26:39   

yes, 'db' is unknown what it is and indeed the qf isn't used so I think linq and queryspec are mixed here.

Frans Bouma | Lead developer LLBLGen Pro
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 15-Jan-2018 12:03:17   

Otis wrote:

yes, 'db' is unknown what it is and indeed the qf isn't used so I think linq and queryspec are mixed here.

Ah, yes, I must have been reading the QuerySpec stuff, while in this case db is a Linq metadata object. The wide range of options for querying data makes it very tricky to work out how to perform non-trivial operations like this. qf was introduced as a test after I crashed and burned trying to use PrefetchPathStreamrow in a Linq operation, so presumably that property serves no purpose in a Linq based operation chain?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 15-Jan-2018 16:50:18   

Indeed, queryfactory is used for queryspec, and linq uses LinqMetaData. If you write a Linq query, you don't need queryfactory and if you write a queryspec query you don't need LinqMetaData.

Linq has different extension methods for prefetchpaths than queryspec.

Frans Bouma | Lead developer LLBLGen Pro