0
I have a problem with the result of the method SaveChanges()
.
I am trying to save a record, and it is persisted in the database, however the application is returning the message from exception
:
{"Undefined object reference for an object instance."}
Applicationservice:
try
{
using (TransactionScope transactionScope = Transactional.ExtractTransactional(this.TransactionalMaps))
{
if (distribuicaoAdmin.ID == 0)
{
this._DistribuicaoAdminService.Add(distribuicaoAdmin);
}
else
{
this._DistribuicaoAdminService.Update(distribuicaoAdmin);
}
this.SaveChanges(transactionScope);
}
}
catch (Exception ex)
{
resultado = "Não foi possível inserir o registro.";
this._SysLogService.Registrar(ex.Message + ex.StackTrace);
return false;
}
When he enters the method this.SaveChages(transactionScope);
is where the exception
.
Object:
One thing I noticed, after the data is persisted, my related objects come back with null value. My other objects are:
- Entity;
- detachment;
- distribution;
- tariff;
Edit 1:
Savechanges Methods:
public int SaveChanges(TransactionScope transactionScope)
{
try
{
var changes = this._ServiceBase.SaveChanges();
transactionScope.Complete();
return changes;
}
catch (Exception ex)
{
throw ex;
}
}
The error is in the excerpt transactionScope.Complete();
.
what is inside the Savechanges ? method in Stacktrace of Exception, checks which line occurs the problem
– Rovann Linhalis
I did an Edit on the question of where the problem comes from. In this Complete() method I can no longer advance: "The symbol no implementations."
– Jonathan de Toni
it is possible that
transactionScope
is null then. The problem comes fromTransactional.ExtractTransactional
but I do not know what the implementation of this.– Rovann Linhalis
I managed to resolve with [Transactional] on the implementation, but now is not saving more kkkk
– Jonathan de Toni
now is not giving the commit so hehe
– Rovann Linhalis
pq vc ta using this transaction scope?
– Ayrton Giffoni
Put what Transactional.Extracttransactional(this.Transactionalmaps) does inside pq as you said you have a problem with the transaction, it may be that the problem is there
– Ayrton Giffoni