Say I have a Sale
class:
public class Sale : BaseEntity //BaseEntity only has an Id
{
public ICollection- Items { get;
@craigmoliver Here's my solution. It is not the best, I know - if you find a more elegant way, please share.
Repository:
public async Task UpdateAsync(TEntity entity, bool save = true, params Expression>[] navigations)
where TEntity : class, IIdEntity
{
TEntity dbEntity = await _context.FindAsync(entity.Id);
EntityEntry dbEntry = _context.Entry(dbEntity);
dbEntry.CurrentValues.SetValues(entity);
foreach (Expression> property in navigations)
{
var propertyName = property.GetPropertyAccess().Name;
CollectionEntry dbItemsEntry = dbEntry.Collection(propertyName);
IClrCollectionAccessor accessor = dbItemsEntry.Metadata.GetCollectionAccessor();
await dbItemsEntry.LoadAsync();
var dbItemsMap = ((IEnumerable
Context:
public IReadOnlyList FindPrimaryKeyProperties(T entity)
{
return Model.FindEntityType(entity.GetType()).FindPrimaryKey().Properties;
}
public IEnumerable