Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace MyApp.Web.Models
- {
- using System;
- using System.Collections.Generic;
- using System.Data.Linq;
- public partial class MyAppDataContext
- {
- public bool DeleteAllOnSubmit<T>(IEnumerable<T> entities)
- {
- try
- {
- GetTable(typeof(T)).DeleteAllOnSubmit(entities);
- SubmitChanges();
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
- public bool DeleteOnSubmit<T>(T entity)
- {
- try
- {
- GetTable(typeof(T)).DeleteOnSubmit(entity);
- SubmitChanges();
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
- public bool InsertAllOnSubmit<T>(IEnumerable<T> entities)
- {
- try
- {
- GetTable(typeof(T)).InsertAllOnSubmit(entities);
- SubmitChanges();
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
- public bool InsertOnSubmit<T>(ref T entity)
- {
- try
- {
- GetTable(typeof(T)).InsertOnSubmit(entity);
- SubmitChanges();
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
- partial void OnCreated()
- {
- var options = new DataLoadOptions();
- // Add loadwith elements
- // options.LoadWith<parentClass>(p => p.columnName);
- LoadOptions = options;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement