Hi,
I'm trying to make long codes short. The original codes does something following:
using (var context = new DataEntities())
{
context.Table1.Foreach(x =>{
// Omit ... updating UI
DoSomething(x);
// Omit ... updating UI
});
context.Table2.Foreach(x =>
{
// Omit ... updating UI
DoSomething(x);
// Omit ... updating UI
});
context.Table3.Foreach(x =>
{
// Omit ... updating UI
DoSomething(x);
// Omit ... updating UI
});
// continue...
}
As you see, there is lots of similar code here. So, I thought I should refactor it though, it's pretty hard for me since I cannot cast context.Table1 to anything, for an example, to cast context.Table1 to ObjectSet<EntityObject>
to implement a method which does all the same action for the tables.
I just want to put similar codes into a method, does anyone have a good idea?
Thanks in advance,
Yoo