My tables have common columns like ‘Operation_Time’ , ‘Create_User’ .
Instead of writing update codes for many types of my entity objects -that is personels,adress etc.- i want to write a static method that will take an entityobject and will update its target fields . With Dataset, DataTable this was very easy .
function updateEntityObjectsCommonFields(EntityObject obj)
{ /// just i guess
obj.Fields["Create_Usr"] = Session.Usr;
obj.Fields["Operation_Time"] = DateTime.Now;
obj.Fields["Last_Op_Usr"] = Session.Usr;
}
/// usage
updateEntityObjectsCommonFields(Person) ;
updateEntityObjectsCommonFields(Adres)
updateEntityObjectsCommonFields(Application) ; ;
Any solutions?
Thanks in advance ?
Let your entities implement a common interface which specifies the fields you need and write your update function in terms of this interface.
You can let them implement the interface by modifying your T4 template (if it applies to all entities) or by letting specific entities implement your interface in the partial class file.