I am stuck on a small problem. I want to remove one row based on an ID. But I keep deleting all my rows instead.
This is my code in my datalayer. You can read the word "eigenaar" as "owner".
public void removeEigenaar(int eigenaarID)
{
transaction = connection.BeginTransaction();
try
{
using (context = new MyDbContext(connection, false))
{
context.Database.Log = (string message) => { Console.WriteLine(message); };
context.Database.UseTransaction(transaction);
//----------------------------
Eigenaar e =
(from s in context.Eigenaars
where s.ID == eigenaarID
select s).First();
context.Eigenaars.Remove(e);
//----------------------------
context.SaveChanges();
}
transaction.Commit();
}
catch
{
transaction.Rollback();
throw;
}
}
If I debug the code, i can see that my "e" is filled with one owner. That's what i find so strange.
edit sql
My delete query works, it just deletes way to much.