Hi
I am developing an application with Xamarin Forms.
What I do is take the data provided as a service and add it to the sqlite database and update it if there is any.
But this process is very slow.
Is there any way I can speed this up?
I searched Bulk Insert but could not find an answer.
My code is here;
```Response<PagedList<ContractListDTO>> contractList = await _ContractService.GetContractList();
if (contractList.CheckSuccess(ResponseSuccessType.ResponseMustSucceeded, ErrorLog, Position + " a ait son 100 sözleşmenin alınması"))
{
await Progress.ResetLevel(3, contractList.Content.Items.Count);
foreach (ContractListDTO contractTerminate in contractList.Content.Items)
{
//progressBar.Progress += 2;
await Progress.Increase(3, "Sözleşme Numarası: " + contractTerminate.ContractNumber);
new ContractDAO().SaveOrUpdate(new Contract()
{
ContractNumber = contractTerminate.ContractNumber,
ContractUniqueNumber = contractTerminate.ContractUniqueNumber,
CustomerCode = contractTerminate.CustomerCode,
CustomerName = contractTerminate.CustomerName,
CustomerType = contractTerminate.CustomerType,
WorkFlowApprovalStatusCode = contractTerminate.WorkFlowApprovalStatusCode,
StartDate = contractTerminate.StartDate,
EndDate = contractTerminate.EndDate
},ContractDataSourceServiceType.ContractList);
new ContractPromotionUserDAO().Save(new ContractPromotionUser()
{
RelationshipType = (int)RelationshipType.ContractList,
ContractUniqueNumber = contractTerminate.ContractUniqueNumber,
UserId = Position.UserId,
PositionId = Position.PositionId,
Type = (int)EnumContractPromotion.Contract,
});
await _SyncTaskCommonService.GetFromOnlineContractDetailToLocale(contractTerminate.ContractUniqueNumber, Position.UserId, Position.PositionId, ErrorLog);
await _SyncTaskCommonService.GetFromOnlineContractPropertyToLocale(contractTerminate.ContractUniqueNumber, ErrorLog);
public void SaveOrUpdate(Contract entity, ContractDataSourceServiceType dataSourceServiceType)
{
if (GetByContractUniqueNumber(entity.ContractUniqueNumber) != null)
{
//_connection.Update(entity);
if (dataSourceServiceType == ContractDataSourceServiceType.PendingApprove
|| dataSourceServiceType == ContractDataSourceServiceType.LastApproved
|| dataSourceServiceType == ContractDataSourceServiceType.Rejected
|| dataSourceServiceType == ContractDataSourceServiceType.ContractList)
{
UpdateByPendingApproveOrLastApprovedOrRejected(entity);
}
else if (dataSourceServiceType == ContractDataSourceServiceType.Terminate)
{
UpdateByTerminate(entity);
}
else if (dataSourceServiceType == ContractDataSourceServiceType.Summary)
{
UpdateBySummary(entity);
}
else if (dataSourceServiceType == ContractDataSourceServiceType.ManVoyEnt)
{
UpdateByManVoyEnt(entity);
}
}
else
Add(entity);
}
public void UpdateByPendingApproveOrLastApprovedOrRejected(Contract entity)
{
_connection.Execute(@"UPDATE Contract SET Id = ?, ContractNumber = ?, CustomerCode = ?, CustomerName = ?, CustomerType = ?, CoaStartDate = ? WHERE ContractUniqueNumber = ?",
entity.Id, entity.ContractNumber, entity.CustomerCode, entity.CustomerName, entity.CustomerType,
entity.CoaStartDate, entity.ContractUniqueNumber);
}
```