I am using Asp.net Zero and i need to use BulkInsert for large data because the normal Insert and Save Changes is very Slow. How do i achieve this in the code below.. See the Repository layer
And this is my Business Logic layer(Application Services) where an calling the Repository Method
I tried using this method
as a method in the Repository Layer but calling the Method in the Bussiness Logic Layer, is giving a compilation error... Is there any better way to do this?
C#:
private readonly IRepository<InventoryBalance> _repository;
public async Task<InventoryBalance> CreateAsync(InventoryBalance input)
{
var item = _repository.Insert(input);
await CurrentUnitOfWork.SaveChangesAsync();
return item;
}
C#:
public async Task< PostMessageDto> BulkUpload(List<InventoryBalanceDto> input)
{
var item = _recEngine.GetList().Where(x=>x.TenantId== _abps.GetTenantId() && x.EntryBy == this.GetUserName() );
if(item.Count() > 0)
{
foreach (var it in item)
{
item.ProceedStatus = false;
await _recEngine.UpdateInvBalanceAsync(it);
}
}
var result = new PostMessageDto { ResponseCode = "00", ResponseDetails = "Successful" };
var newList = new List<InventoryBalanceDto>();
newList = input;
if (input.Count() == 0)
{
result.ResponseCode = "99";
result.ResponseDetails = "No valid record";
}
else
{
foreach (var Value in input.ToList())
{
var acct = new InventoryBalance();
acct.BankStmtCloseBal = Value.BankStmtCloseBal;
acct.BankStmtOpenBal = Value.BankStmtOpenBal;
acct.CashBookCloseBal = Value.CashBookCloseBal;
acct.CashBookOpenBal = Value.CashBookOpenBal;
acct.AccountNumber = Value.AccountNumber;
acct.CompanyCode = this.CompanyCode();
acct.TenantId = _abps.GetTenantId();
acct.ProceedStatus = true;
acct.EndDate = Value.Enddate;
acct.EntryBy = this.GetUserName();
acct.EntryDate = DateTime.Now;
acct.StartDate = Value.StartDate;
await _recEngine.CreateAsync(acct);
}
}
return result;
}
C#:
public void CreateBulk(IList<InventoryBalance> inputs)
{
_repository.GetDbContext().BulkInsert(Inputs);
}
Last edited by a moderator: