1
They asked me this question: What is OLTP? I ran home, opened google and started to "goolgar", so I came across these codes, who say they have problems in OLTP environments and I’m not understanding bulhufas:
public JsonResult ListarAlocacoes(AlocacaoView alocacaoView)
{
var contratosAlocacaoList = ObterContratosAlocacao(alocacaoView);
/* ... */
}
private IList<AlocacaoJson> ObterContratosAlocacao(AlocacaoView alocacaoView = null)
{
var contratoList = BaseContext.DbContext.Set<Contrato>().Include("ContratoValores").ToList();
foreach (var contrato in contratoList.Where( /* ... */ ))
{
var alocacao = MontarAlocacao(contrato, alocacaoView.CompetenciaId);
/* ... */
}
/* ... */
}
private AlocacaoJson MontarAlocacao(Contrato contrato, DateTime dataCompetencia, int? equipeId = null)
{
var alocacao = new AlocacaoJson();
/* ... */
alocacao.Equipe = ObterEquipeContrato(contrato, equipeId);
alocacao.CustoTotal = ObterCustoTotalContrato(contrato, dataCompetencia);
/* ... */
}
private EquipeJson ObterEquipeContrato(Contrato contrato, int? equipeId)
{
var equipe = BaseContext.DbContext.Set<Equipe>().Find(equipeId.Value);
/* ... */
}
private CustoTotalJson ObterCustoTotalContrato(Contrato contrato, DateTime dataCompetencia)
{
var competencia = BaseContext.DbContext.Set<Competencia>().Where(c => c.Data == dataCompetencia).First(); ;
var alocacao = BaseContext.DbContext.Set<Alocacao>().Include("AlocacoesProjeto").Include("Contrato").Include("Equipe").SingleOrDefault(c => c.CompetenciaData == competencia.Data);
var valorHora = BaseContext.DbContext.Set<Funcao>().Find( /* ... */ ).ValoresHoras.SingleOrDefault( /* ... */ );
var custoTotal = (decimal)(valorHora.Valor * alocacao.QtdeHoras) /* ... */;
/* ... */
}
In a production environment, would that support an OLTP approach? Why?
You may have seen, but I leave no reference: https://social.technet.microsoft.com/wiki/contents/articles/6934.oltp-x-olap-pt-br.aspx
– Rovann Linhalis
The OLTP term is most associated with database design, the main features of the systems (most) that adopt this approach are standard tables/entities and transaction orientation. Another model is the OLAP used in Dataware Houses its focus is on reading data so it is less normalized than OLTP.
– rray
If I understand correctly, if no transactions are used in the database, the above code can produce inconsistent results.
– bfavaretto
Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?
– Maniero