0
Good afternoon Gentlemen.
I’m facing a problem I’ve never seen before, below I have a view mapped in the EF with effluent
var viewRelatorio = db.view.where(ra.DataBruta.Month == mesAno.Month).toList();
I have two dictionaries that will interact with the data in this view
var rel1 = new Dictionary<int, Relatorio>();
var relItemVirada = new Dictionary<int, Relatorio>();
var relatorio = new Relatorio>();
var eventoFinal = false
I read the view for iteration with dictionaries
foreach (var item in viewRelatorio)
{
rel1.Add(i, item);
if (item.HorarioInicial.StartsWith("23") && item.HorarioFinal.StartsWith("00"))
{
relatorio = item;
relatorio.HorarioFinal = "235959";
relItemVirada.Add(i, relatorio);
}
i++;
}
What happens is that every time I change the value in report.Timefinal it changes the original value in item that does not undergo any kind of change, I would like to know what this might be ?
I have tried to interact in several ways, different loops, directly in the item, whenever I touch an item affects the next or vice and versa
follows the Fluent mapping
public RelatorioConfiguration()
: base("name=" + ConfigurationManager.AppSettings["databaseInstance"].ToString())
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
var relatorio = modelBuilder.Entity<Relatorio>();
relatorio.ToTable("view_Relatorio");
relatorio.HasKey(p => new {p.DataBruta, p.HorarioInicial});
relatorio.Property(p => p.Ano);
relatorio.Property(p => p.Classificacao);
relatorio.Property(p => p.DataBruta);
relatorio.Property(p => p.HorarioFinal);
relatorio.Property(p => p.HorarioInicial);
}
public DbSet<Relatorio> Relatorio { get; set; }
I don’t know if it has anything to do with it, but it could be the Entity Changetracker understanding that you are editing a table item, try using db.view.Asnotracking(). Where(ra.DataBruta.Month == mesAno.Month). toList();' thus disables Changetracker
– Julio Borges