Skip to content

Eager-Loading nav properties within the generic repo implementation? #4

@diegohb

Description

@diegohb

Any particular reason to not include a way specify properties to eager load? Just wondering if there was something wrong with that.. I'm thinking I rather isolate all EF-specifics including the .Includes() calls to the same assembly as my generic repo implementation assembly.

I added params to GetQuery<>() and its overloads:

Queryable<TEntity> GetQuery<TEntity>(params Expression<Func<TEntity, object>>[] pExpandPropertySelectors) 

and before return the objectQuery:

if (pExpandPropertySelectors != null)
            {
                objectQuery = pExpandPropertySelectors.Aggregate
                    (objectQuery, (pCurrent, pInclude) => pCurrent.Include(pInclude) as ObjectQuery<TEntity>);
            }

also modified the GetByKey method to make a call out to DbContext.Entry(entityObject).Reference/Collection.Load() ..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions