//using Bro.Process.Model; //using System; //using System.Collections.Generic; //using System.Configuration; //using System.Data.Common; //using System.Data.Entity; //using System.Data.SQLite; //using System.Linq; //using System.Reflection; //using System.Text; //using System.Threading.Tasks; //namespace Bro.Process.DataBase //{ // public class ModelManager where T : BaseModel, new() // { // private PropertyInfo TableProperty = null; // public static string ConnectionString = ConfigurationManager.ConnectionStrings["DBModel"].ConnectionString; // public ModelManager() // { // T t = new T(); // using (DBModel db = new DBModel()) // { // TableProperty = db.GetType().GetProperties().FirstOrDefault(u => u.Name == t.GetType().Name); // } // } // public void NewModel(T t, string userId = "") // { // using (DBModel context = new DBModel()) // { // ActionBeforeNewModel(context, t); // t.SetNew(userId); // (TableProperty.GetValue(context) as DbSet).Add(t); // context.SaveChanges(); // } // } // public void BatchAdd(List t, string userId = "") // { // using (DBModel context = new DBModel()) // { // (TableProperty.GetValue(context) as DbSet).AddRange(t); // context.SaveChanges(); // } // } // public void UpdateModel(T t, string userId = "") // { // using (DBModel context = new DBModel()) // { // ActionBeforeUpdateModel(context, t); // DbSet set = TableProperty.GetValue(context) as DbSet; // T oldT = set.FirstOrDefault(u => u.ID == t.ID); // oldT.DataTransfer(t); // oldT.SetUpdate(userId); // context.SaveChanges(); // } // } // public void DeleteModel(string id, bool isDelete = true, string userId = "") // { // using (DBModel context = new DBModel()) // { // ActionBeforeDeleteModel(context, id); // DbSet set = TableProperty.GetValue(context) as DbSet; // T oldT = set.FirstOrDefault(u => u.ID == id); // oldT.IS_DELETED = isDelete ? 1 : 0; // oldT.SetUpdate(userId); // context.SaveChanges(); // } // } // public void DisableModel(string id, bool isDisable = true, string userId = "") // { // using (DBModel context = new DBModel()) // { // ActionBeforeEnableModel(context, id); // DbSet set = TableProperty.GetValue(context) as DbSet; // T oldT = set.FirstOrDefault(u => u.ID == id); // oldT.IS_DISABLED = isDisable ? 1 : 0; // oldT.SetUpdate(userId); // context.SaveChanges(); // } // } // #region "" // protected virtual void ActionBeforeNewModel(DBModel context, T t) // { // } // protected virtual void ActionBeforeUpdateModel(DBModel context, T t) // { // } // protected virtual void ActionBeforeDeleteModel(DBModel context, string id) // { // } // protected virtual void ActionBeforeEnableModel(DBModel context, string id) // { // } // #endregion // } //}