Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pubic class ConcretePublicObjectOne : IPublicObject{}
- static void Save<T>(T item)
- where T : class, IPublicObject
- {
- using (DataContext ctx = GetDataContext())
- {
- Table<T> table = ctx.GetTable<T>();
- // for insert...
- table.InsertOnSubmit(item);
- // for update...
- table.Attach(item, true);
- // for delete...
- table.DeleteOnSubmit(item);
- ctx.SubmitChanges();
- }
- }
- Foo foo = new Foo();
- Save(foo); // <Foo> is inferred
- Repository.Save(publicObject)
- public class Repository {
- public void Save(IPublicObject publicObject) {
- publicObject.Save();
- }
- }
- public interface IPublicObject {
- void Save();
- }
Add Comment
Please, Sign In to add comment