forked from ddrilling/AsbCloudServer
Fix CrudServiceBase.Insert*: set "Id" prop to 0 before inserrt.
This commit is contained in:
parent
2173f6593f
commit
b9eaf36a65
@ -84,13 +84,19 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
public virtual Task<int> InsertAsync(TDto item, CancellationToken token = default)
|
public virtual Task<int> InsertAsync(TDto item, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var entity = Convert(item);
|
var entity = Convert(item);
|
||||||
|
entity.Id = 0;
|
||||||
dbSet.Add(entity);
|
dbSet.Add(entity);
|
||||||
return context.SaveChangesAsync(token);
|
return context.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task<int> InsertRangeAsync(IEnumerable<TDto> items, CancellationToken token = default)
|
public virtual Task<int> InsertRangeAsync(IEnumerable<TDto> items, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var entities = items.Select(i => Convert(i));
|
var entities = items.Select(i => {
|
||||||
|
var entity = Convert(i);
|
||||||
|
entity.Id = 0;
|
||||||
|
return entity;
|
||||||
|
});
|
||||||
|
|
||||||
dbSet.AddRange(entities);
|
dbSet.AddRange(entities);
|
||||||
return context.SaveChangesAsync(token);
|
return context.SaveChangesAsync(token);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user