When I save an existing entity in my project, if I don't include the child on the DbSet, it lose the previous value. I can't figure out what's wrong with this project, I do not have to do this in my others projects.
Some code :
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 where we are missing some includes, so we lose data.
0 comments:
Post a Comment