I am using asp.net and c#.
I have a some classes. Some of the classes are having same met开发者_运维问答hods insert, update and delete.
Each insert will insert different data to different table. (same for update and delete). What type of pattern can be applied for this kind of class.
please suggest.
Patterns are things you should identify in your code from usage. Choosing a design pattern and then applying it, is perhaps a classic mistake.
Use a pattern, where a pattern is required.
Uhm... Generics?
Otherwise this sounds like the Template Method pattern.
While I agree wholeheartedly with Mitch Wheat, based on your description I do believe you're already using a pattern, without being aware of it completely.
Based on you description, I believe you are talking about the Table Gateway pattern. Each class represents access to a specific table, so you can perform your CRUD operations on a class. This offers a very tight binding of your model to your database logic, which can sometimes be useful (and more often than not can become very restrictive).
BTW: I am making the assumption here that when you say "each insert will insert different data to different table (same for update and delete)", you actually meant "each class".
精彩评论