urfnet / URF.Core

Unit of Work & Repositories Framework - .NET Core, NET Standard, Entity Framework Core. 100% extensible & lightweight.
https://github.com/urfnet
MIT License
309 stars 62 forks source link

[question] Why there is a method to load a reference property but not a method to load a collection property from Repository ? #74

Open rdhainaut opened 4 years ago

rdhainaut commented 4 years ago

I have noticed that there is a "generic" method to load a "reference" property but not a "collection" property in the repository code. I don t understand why there is a distinction and so no generic method for a collection property ?

Actual code for reference property

public virtual async Task LoadPropertyAsync(TEntity item, Expression<Func<TEntity, object>> property, CancellationToken cancellationToken = default)
            => await Context.Entry(item).Reference(property).LoadAsync(cancellationToken);

A proposition for collection property

public virtual async Task LoadCollectionAsync(TEntity item, Expression<Func<TEntity, IEnumerable<object>>> property, CancellationToken cancellationToken = default)
            => await Context.Entry<TEntity>(item).Collection(property).LoadAsync(cancellationToken);
tonysneed commented 4 years ago

This sounds like a good idea. Would you care to submit a PR?

rdhainaut commented 4 years ago

I will look at this monday :)

rdhainaut commented 4 years ago

75 it s done