Coder Social home page Coder Social logo

npublic.dapper's Introduction

NPublic.Dapper

image

NPublic.Dapper重新以.NET Standard封装Dapper并增加数据库操作错误日志。
适用.NET Core,.NET Framework(.NET Framework会生成很多DLL,后续考虑Windows平台可单独封装一个版本)

.NET Standard 是 .NET Core 和 .NET Framework 共有的基础。

重新封装后的优点:
1.对原有Dapper继承,不会有性能损耗。
2.支持MySql,SqlServer,SqlLite,Oracle等常见数据库
3.捕获一切数据库相关异常行为 如,
<1>极少情况下,极少用户操作与数据库有关的异常
<2>用户试探性攻击,注入
<3>快速定位系统异常出现的位置,错误的SQL语句
4.上述异常由NPublic.Dapper数据库层统一处理。开发过程不再关心这些异常,专注业务开发。

5.NPublic.Dapper将异常日志压入MQ队列,以下情况可根据需要自行扩展
<1>实时取队列数据,即可实时显示系统所有错误日志
<2>可轻松应对大规模分布式日志处理
<2>对特定日志,可直接发送邮件提示
<3>加密解密,可根据需要对日志进行加密保存,用特定工具才能访问
<4>使用特定工具,监控log日志文件,环比,同比增加X即报警提示

【数据库操作Demo】
NDapper db = DapperManager.CreateDatabase(ConnectionStr1, DBType.SqlServer);
var list= db.Query("select id,symbol from tb");//查询SqlServer

NDapper mdb1 = DapperManager.CreateDatabase(ConnectionStr1, DBType.MySql);
var list1 = mdb1.Query("select id,symbol from tb1");//查询MySql数据库1的tb1数据表,返回Model

NDapper mdb2 = DapperManager.CreateDatabase(ConnectionStr2, DBType.MySql);
var list2 = mdb2.Query("select id,symbol from tb2");//查询MySql数据库2的tb2数据表,返回Model

NDapper dbSqlLite = DapperManager.CreateDatabase(@"symbo.db", DBType.SqlLite);
string createtb = "create table tb1 (id int, symbol varchar(50))";//SqlLite数据库中创建tb1数据表
int x = dbSqlLite.Execute(createtb);


【异常错误日志格式】
2020-08-26 10:30:53 - 169.254.120.171
Query:select id,symbol from tb1
对象名 'tb1' 无效。

2020-08-26 10:30:54 - 169.254.120.171
Query:select id,symbol from tb2
对象名 'tb2' 无效。

2020-08-26 10:30:54 - 169.254.120.171
Query:select id,symbol from tb001
SQLite Error 1: 'no such table: tb001'.

npublic.dapper's People

Contributors

dxwong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.