I'm working on a template-based C# application.
This application saves entries to a database, using the procedure database.SaveChanged()
.
I would like to see the list of things which are to be changed, which can be done, using the following method:
IList<T> GetChanged<T>() where T : class;
This means that I could do this as follows:
foreach (var t in database.GetChanged<Alarm>())
{
log.Debug($"DB Change=[{t}]");
}
foreach (var t in database.GetChanged<Area>())
{
log.Debug($"DB Change. ClassName=[{t.GetType()}], Change=[{t}]");
}
...
As I have tens of classnames (Alarm
and Area
are just two out of the fifty-three cases), I would like to do this in an easier way, something like:
List<ClassNames> Class_List= {Alarm, Area, ..., Server.Domain.ClassName, ...};
// indeed, namespaces are possible
foreach (var entry in Class_List)
{
foreach (var t in database.GetChanged<entry>())
{
log.Debug($"DB Change. ClassName=[{entry}], Change=[{t}]");
}
}