Hakkı
Hakkı

Reputation: 840

Linqpad is not submitting changes

I don't know what i miss. I used it thousands of time and I updated millions of rows before.

There are two tables. One is storing definitions. One is storing relations years based. Some relations are inserted wrong years. I want to update these rows.

This is my linqpad query.

var list = ABSPaylarOlcmeProgram.Where(x => x.FKPaylarOlcme.FKPaylar.Yil != x.FKProgramCikti.Yil).ToList(); 

  foreach (var element in list)
    {
        Console.WriteLine(element.FKProgramCiktiID);
        element.FKProgramCiktiID = BolumYeterlilik.First(x=> x.FKProgramBirimID == element.FKProgramCikti.FKProgramBirimID && x.Yil == element.FKPaylarOlcme.FKPaylar.Yil && x.Sira == element.FKProgramCikti.Sira).ID;
        Console.WriteLine(element.FKProgramCiktiID);
    }
    SubmitChanges();

ABSPaylarOlcmeProgram = relations table.

BolumYeterlilik = definitions table.

In the list I found wrong relations which are years not equals. In foreach I use element.FKProgramCiktiID for the correct definition Id. It updates when I write integer value. But It not submit changes If I query BolumYeterlilik.First

What is the problem? Anything related changes tracking?

Upvotes: 0

Views: 75

Answers (2)

sgmoore
sgmoore

Reputation: 16077

element.FKProgramCiktiID should work but only if element.FKProgramCikti has not been accessed.

And in your query, it is being accessed as subquery contains element.FKProgramCikti.FKProgramBirimID

Upvotes: 1

Hakkı
Hakkı

Reputation: 840

I solved the problem but not the way I want.

I was directly finding definition id and assign it to the value. It resets value when I call SubmitChanges(). This is still not working.

But when I directy assign foreign table record it worked.

Not working

element.FKProgramCiktiID = ....

Working

element.FKProgramCikti = ....

Upvotes: 0

Related Questions