From 27963d4c2b470bfe37243702a99ff5da7b8c5331 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期六, 27 六月 2020 15:04:00 +0800
Subject: [PATCH] merge

---
 src/Bro.Process.DBManager/ModelManager.cs |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/src/Bro.Process.DBManager/ModelManager.cs b/src/Bro.Process.DBManager/ModelManager.cs
new file mode 100644
index 0000000..20855a6
--- /dev/null
+++ b/src/Bro.Process.DBManager/ModelManager.cs
@@ -0,0 +1,113 @@
+锘�//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<T> 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<T>).Add(t);
+
+//                context.SaveChanges();
+//            }
+//        }
+
+//        public void BatchAdd(List<T> t, string userId = "")
+//        {
+//            using (DBModel context = new DBModel())
+//            {
+//                (TableProperty.GetValue(context) as DbSet<T>).AddRange(t);
+//                context.SaveChanges();
+//            }
+//        }
+
+//        public void UpdateModel(T t, string userId = "")
+//        {
+//            using (DBModel context = new DBModel())
+//            {
+//                ActionBeforeUpdateModel(context, t);
+
+//                DbSet<T> set = TableProperty.GetValue(context) as DbSet<T>;
+//                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<T> set = TableProperty.GetValue(context) as DbSet<T>;
+//                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<T> set = TableProperty.GetValue(context) as DbSet<T>;
+//                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
+//    }
+//}

--
Gitblit v1.8.0