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
c # entity-framework


source to share


No one has answered this question yet

See similar questions:

nineteen
Lightweight, lazy and explicit loading in EF6

or similar:

1266
How do I update the GUI from another thread?
783
Entity Framework vs LINQ to SQL
758
Entity Framework 5 Record Update
756
Failed to check for one or more objects. For more information, see "EntityValidationErrors Property".
630
Fastest way to insert into Entity framework
515
How can I get the ID of the inserted entity in the Entity framework?
461
How do I view the SQL generated by the Entity Framework?
443
SqlException from Entity Framework - new transaction is not allowed because there are other threads in the session
401
Entity Framework Service Provider not found for ADO.NET Provider with invariant name 'System.Data.SqlClient'
328
Entity cannot be built in LINQ to Entities query



All Articles
Loading...
X
Show
Funny
Dev
Pics