I decided to open a new Issue since this is another matter.
The InsertAsync method returns an object[] type but I wonder why you decided to hide the default EntityEntry return type.
If the goal is to simplify and just return the primary key, then this could be done without hiding EntityEntry by using the following definition:
public async Task<(EntityEntry entity, object[] primaryKey)> InsertAsync<T>(T entity, CancellationToken cancellationToken = default)
where T : class
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
EntityEntry<T> entityEntry = await _dbContext.Set<T>().AddAsync(entity, cancellationToken).ConfigureAwait(false);
await _dbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
object[] primaryKeyValue = entityEntry.Metadata.FindPrimaryKey().Properties.
Select(p => entityEntry.Property(p.Name).CurrentValue).ToArray();
return (entityEntry, primaryKeyValue);
}
HI once again,
I decided to open a new Issue since this is another matter.
The InsertAsync method returns an object[] type but I wonder why you decided to hide the default EntityEntry return type. If the goal is to simplify and just return the primary key, then this could be done without hiding EntityEntry by using the following definition:
What do you think of this?