Refreshes the flash object is a child object in EF
When I save an existing object in my project, if I don't include it in the DbSet, it will lose its previous value. I can't figure out what's wrong with this project, I don't need to do this in my other projects.
Some codes:
var quoteRequest = _session.Set<QuoteRequest>()
.Include(x => x.QuoteRequestInvites)
.Include(x => x.QuoteRequestInvites.Select(y => y.SelectedService))
.Include(x => x.QuoteRequestInvites.Select(y => y.SelectedService).Select(z => z.Service))
.Include(x => x.QuoteRequestInvites.Select(y => y.Provider))
.Include(x => x.District)
.Include(x => x.City)
.FirstOrDefault(x => x.Id == quoteRequestId);
if (quoteRequest == null)
return Request.CreateResponse(HttpStatusCode.NotFound);
foreach (var invite in quoteRequest.QuoteRequestInvites)
{
if (invite.Token == Guid.Empty)
{
_logger.Warn(invite, "Empty token changed for invite " + invite.Id);
invite.Token = Guid.NewGuid();
_session.Commit();
}
}
_providerMailerService.ProcessInvites(quoteRequest);
_customerMailerService.ProcessNotification(quoteRequest);
_session.Attach(administrator);
quoteRequest.ApprovalDate = DateTime.UtcNow;
quoteRequest.ApprovedBy = administrator;
_session.Commit();
The problem is that there is somewhere in the project that we are missing and therefore we are losing data.
+3
source to share
No one has answered this question yet
See similar questions:
or similar: