You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
What do you think of this?
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: