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;
}
}
}
Comments