# GFORMFrame **Repository Path**: cnXYZ/GFORMFrame ## Basic Information - **Project Name**: GFORMFrame - **Description**: 支持多数据库 user_DB shop_DB 支持异构数据库 如 mysql oracle msssql access txt sqlslite db csv SqlServerCe excel 等 支持数据库主从链接内容 支持 DAPPER 支持 HELPER 支持实体映射 未来会 或者已经支持EF 内容 本项目使用 2.0 架构开发 和引入 因为站在巨人们的肩膀上 未来会结合mycat 处理内容观察 - **Primary Language**: C# - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2020-07-03 - **Last Updated**: 2022-01-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GFORMFrame 支持多数据库 user_DB shop_DB 支持异构数据库 如 mysql oracle msssql access txt sqlslite db csv SqlServerCe excel 等 支持数据库主从链接内容 Conscbuji2Conn_Slave1 Conscbuji2Conn_Slave2 ... 支持 DAPPER 支持 HELPER dbhelper 支持实体映射 select 未来会 或者已经支持EF 内容 本项目使用 2.0 架构开发 和引入 因为站在巨人们的肩膀上 包括cydata dapper EFcore 未来会结合mycat 处理内容观察 APP.config 或者 web.config 的支持内容为: 如果出现问题请 提交相应的readme.MD 谢谢 联系方式为 :QQ:884269094
Demo static void Main(string[] args) { string providename; //bool result = DBTool.TestConn(AppConfig.DB.DefaultConn);//检测数据库链接是否正常 //OutMsg("数据库链接:" + result); //new MAction(Conscbuji2Enum.shipformulaa,AppConfig.GetConn("Conscbuji2Conn", out providename)) using (MAction action = new MAction(CrossDb.GetEnum("shipformulaa"))) { MDataTable dt; dt = action.Select(1, 10, "order by " + action.Data.PrimaryCell.ColumnName + " desc"); Console.WriteLine(dt.Rows.Count); Console.WriteLine(dt.ToJson(false, false,false)); } //CrossDb.GetEnum("peibi") //,AppConfig.GetConn("zzld_sckzConn", out providename) Console.WriteLine("---------------------------------------------------------------"); using (MAction action = new MAction(CrossDb.GetEnum("peibi"))) { MDataTable dt; dt = action.Select(1, 10, "order by " + action.Data.PrimaryCell.ColumnName + " desc"); Console.WriteLine(dt.Rows.Count); Console.WriteLine(dt.ToJson(false, false, false)); //action.ConnectionString; //dbunnity; //DbBase db = DalCreate.CreateDal(DefaultConn); } Console.WriteLine("---------------------------------------------------------------"); //DBFast helper = CYQ.Data.DalCreate.CreateDal(AppConfig.GetConn("zzld_sckzConn", out providename)); //链接的共用和复用处理 // Console.WriteLine("----------------------"); // // //using (GBFramer gf = GBFramer.GetInstance()) //{ //} { GBFramer gf = ORMHelper.DB; Console.WriteLine(gf.Mainconectstring); //gf.DbConnecttionTwo; if (gf.DbConnecttionTwo.State == System.Data.ConnectionState.Closed) { gf.DbConnecttionTwo.Open(); } var r = gf.DbConnecttionTwo.Execute(@" insert into con02para(con02parid, con0201, con0202, con0203, con0204) values (@a, @b,@c,@d,@e) ", new[] { new { a = Math.Abs(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0)) , b = 1, c = 1, d = DateTime.Now.ToString(), e = 1 } ,new { a = Math.Abs(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0)), b = 2, c = 2, d = DateTime.Now.ToString(), e = 2 } ,new { a = Math.Abs(BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0)), b = 3, c = 3, d = DateTime.Now.ToString(), e = 3 } }); Console.WriteLine("插入结果为:" + r.ToString()); var a = gf.DbConnecttionTwo.Query ("select formulaid, shipid2, formulatype, bujino, item01, item02, item03, item04, item05, item06, item07, item08, item09, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item01gg, item02gg, item03gg, item04gg, item05gg, item06gg, item07gg, item08gg, item09gg, item10gg, item11gg, item12gg, item13gg, item14gg, item15gg, item16gg, item17gg, item18gg, item19gg, item20gg, item21gg, item22gg, item23gg, item24gg, item25gg, strength, slump, diameter, datatype, updid, updtime, slumpdiff, memo, item01name, item02name, item03name, item04name, item05name, item06name, item07name, item08name, item09name, item10name, item11name, item12name, item13name, item14name, item15name, item16name, item17name, item18name, item19name, item20name, item21name, item22name, item23name, item24name, item25name from Shipformulaa where bujino>@id", new { id = "0" }); //conn.Close(); List lstparams = new List(); //SqlParameter DbParameter para = ORMHelper.DB.Biz.Dao.CreateParameter("@id", DbType.Int32, 0); lstparams.Add(para); DataTable dt = ORMHelper.DB.Dapper.ExecuteDataTable("select formulaid, shipid2, formulatype, bujino, item01, item02, item03, item04, item05, item06, item07, item08, item09, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item01gg, item02gg, item03gg, item04gg, item05gg, item06gg, item07gg, item08gg, item09gg, item10gg, item11gg, item12gg, item13gg, item14gg, item15gg, item16gg, item17gg, item18gg, item19gg, item20gg, item21gg, item22gg, item23gg, item24gg, item25gg, strength, slump, diameter, datatype, updid, updtime, slumpdiff, memo, item01name, item02name, item03name, item04name, item05name, item06name, item07name, item08name, item09name, item10name, item11name, item12name, item13name, item14name, item15name, item16name, item17name, item18name, item19name, item20name, item21name, item22name, item23name, item24name, item25name from Shipformulaa where bujino>@id", lstparams, 300, ORMHelper.DB.ProviderName); Console.WriteLine(dt.Rows.Count); Console.WriteLine("============================"); //这里引入对应newjson string jsondt = string.Empty; jsondt = JsonConvertHelper.Serialize(dt); List lstshipfa = new List(); lstshipfa = (List)JsonConvertHelper.Deserialize(jsondt, lstshipfa.GetType()); Console.WriteLine(lstshipfa.Count); Console.WriteLine(jsondt); // a.ToList(); Console.WriteLine(JsonHelper.ToJson(a, false)); Console.WriteLine("==============下面是多结果集内容============="); List lstparams2 = new List(); //SqlParameter DbParameter para2 = ORMHelper.DB.Biz.Dao.CreateParameter("@id", DbType.Int32, 0); lstparams2.Add(para2); DataSet ds = ORMHelper.DB.Dapper.ExecuteDataSet( @" select formulaid, shipid2, formulatype, bujino, item01, item02, item03, item04, item05, item06, item07, item08, item09, item10, item11, item12, item13, item14, item15, item16, item17, item18, item19, item20, item21, item22, item23, item24, item25, item01gg, item02gg, item03gg, item04gg, item05gg, item06gg, item07gg, item08gg, item09gg, item10gg, item11gg, item12gg, item13gg, item14gg, item15gg, item16gg, item17gg, item18gg, item19gg, item20gg, item21gg, item22gg, item23gg, item24gg, item25gg, strength, slump, diameter, datatype, updid, updtime, slumpdiff, memo, item01name, item02name, item03name, item04name, item05name, item06name, item07name, item08name, item09name, item10name, item11name, item12name, item13name, item14name, item15name, item16name, item17name, item18name, item19name, item20name, item21name, item22name, item23name, item24name, item25name from Shipformulaa where bujino>@id; select top 10 queuekey, carid, formulaid, bujiqty, shiptime, engname, workpart, sumno, sumqty, empid, empname, shipaddr, bujistatus, bujistime, formulatype, shipid2, datatype, updid, updtime, othertxt01, othertxt02, othertxt03, Ordid, Pbqty, pb12, pb33, ph14, ph18, logtype, logupdid, logupdtime, pb15a, pb22 from bujiq1alog ; ", lstparams2, 300, ORMHelper.DB.ProviderName); Console.WriteLine(JsonConvertHelper.Serialize(ds)); //bmdbConn GBFramer bmdbgf = ORMHelper.GetDBbyDBname("bmdb"); DataSet ds2 = bmdbgf.Dapper.ExecuteDataSet( @" select * from strength ", null, 300, bmdbgf.ProviderName); Console.WriteLine("==============下面跨数据库的内容============="); Console.WriteLine(JsonConvertHelper.Serialize(ds2)); Console.WriteLine("==============下面多数据库相应的内容============="); using (MAction action = bmdbgf.GetMAction("strength")) { MDataTable dt2; dt2 = action.Select(1, 10, "order by " + action.Data.PrimaryCell.ColumnName + " desc"); Console.WriteLine(dt2.Rows.Count); Console.WriteLine(dt2.ToJson(false, false, false)); } } 核心框架 core public static class ORMHelper { private static readonly object LockObj = new object(); private static GBFramer _db; private static GBFramer _db2; public static GBFramer DB { get { if (_db == null) { lock (LockObj) { if (_db == null) { _db = new GBFramer(); } } } return _db; } } public static GBFramer GetDBbyDBname(string database) { if (_db2 == null) { lock (LockObj) { if (_db2 == null) { _db2 = new GBFramer(database); } } } return _db2; } //GBFramer }