Um neue Projekte hinzuzufügen sollte man update ausführen
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
@@ -74,7 +75,19 @@ namespace KanSan.Base
|
||||
public void Update(TEntity entityToUpdate)
|
||||
{
|
||||
dbSet.Attach(entityToUpdate);
|
||||
context.Entry(entityToUpdate).State = EntityState.Modified;
|
||||
IDatabaseEntry x = (entityToUpdate as IDatabaseEntry);
|
||||
if(x == null)
|
||||
return;
|
||||
if(x.ID.Equals(0))
|
||||
{
|
||||
// Scheint ein neuer Eintrag zu sein
|
||||
context.Entry(entityToUpdate).State = EntityState.Added;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Entry(entityToUpdate).State = EntityState.Modified;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user