views:

389

answers:

1

How to achieve generic Save and Update operation using generics and reflection in C#?

I have achieved data retrieve using some reference from here...

I don't have much time to learn technologies like NHibernate/LINQ/Entity Frameowrk, etc. for this moment. I need a quick solution for this problem for some reason.

+3  A: 

I think you'd be better of using an ORM -- LINQ to SQL, LINQ to Entities, LINQ to nHibernate -- rather than reinventing all of this. Essentially, what you are asking advice on doing has already been done for you in these frameworks/technologies. My advice is to spend some time learning about the tools that already exist and apply your creative energy to adding value to your application, using the already developed tools for the mundane work. Unless, of course, you're looking to implement an ORM because the existing ones are inadequate for your needs. I suspect this isn't the case, otherwise you'd already know how to use reflection to do what you're asking.

tvanfosson
plz see the update.
In my experience, learning to use LINQ-to-SQL is faster than writing your own reflection-based mechanism to do CRUD. Essentially, you drag your tables on to the designer surface and use the created context/entities. You'll need to add your business logic, but you can do that with partial class implementations on the entities.
tvanfosson