Marten: Add support for including child collection objects

Created on 19 Jul 2016  路  7Comments  路  Source: JasperFx/marten

For post-1.0, add support for allowing Include on child collection objects:

var items = new List<Item>();
session.Query<User>().Include(u => u.Collection.Select(c => c.ItemId), items);
enhancement linq

Most helpful comment

Believe it or not we're finally working on this again. This time I want to consider using Common Table Expressions in Postgresql to pull off the fetching

All 7 comments

Maybe something like

SELECT * FROM public.mt_doc_issuelist as il
INNER JOIN public.mt_doc_issue i on (il.Data->'Issues') @> to_jsonb(t.Id)
-- or from Marten object serialization (in this case yielding equal execution plans)
SELECT * FROM public.mt_doc_issuelist as il
INNER JOIN public.mt_doc_issue i on (il.Data->'Issues') @> (t.Data->'Id')

C# public class IssueList { public List<Guid> Issues { get; set; } ... } query.Query<IssueList>().Include<Issue>(x => x.Issues, i => issuesFromDb.Add(i))
By quick glance, the current implementation of IncludeJoin does not seem to favour this, though.

Maybe this would help do it in one call: https://tech.npras.in/postgres-recursive-query/

Well, I hope to take a look at this in the near future. But just by gut feeling & past memory, I can see #834 relating. So addressing how LINQ expressions are evaluated, exposed and translated in the pipeline might provide better & more generalizable benefits overall, instead of attacking the problems case-by-case with a very spefic constructs built around the existing pipeline.

@jokokko Are you up for helping out on this if we really do take it on? Gonna put it off until I clear up a bit and get over the flu first though;-)

@jeremydmiller Yeah I hope to help. Overall, I have to go through code to identify scenarios with dance around queries that the current LINQ provider cannot translate.

Believe it or not we're finally working on this again. This time I want to consider using Common Table Expressions in Postgresql to pull off the fetching

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jinhong- picture jinhong-  路  7Comments

jason-roberts picture jason-roberts  路  3Comments

mhabibal13 picture mhabibal13  路  5Comments

jeremydmiller picture jeremydmiller  路  6Comments

lahma picture lahma  路  4Comments