private static void ApplyChanges<TEntity>(TEntity root) where TEntity : class, IObjectWithState
{
using (var context = new BreakAwayContext())
{
context.Set<TEntity>().Add(root);
CheckForEntitiesWithoutStateInterface(context);
foreach (var entry in context.ChangeTracker.Entries<IObjectWithState>())
{
IObjectWithState stateInfo = entry.Entity;
entry.State = ConvertState(stateInfo.State);
if (stateInfo.State == State.Unchanged)
{
var databaseValues = entry.GetDatabaseValues();
entry.OriginalValues.SetValues(databaseValues);
}
}
context.SaveChanges();
}
}
I am reading a book about Entity Framework and faced a function declaration like above. As my understanding; where clause is defining type of TEntity. So if we choose to define type of TEntity, why not use strongly typed parameter instead of using Generics?
Am I missing something? And what is the terminology is being used for this type of declaration?