SqlSugarCore
SqlSugar 是一款简单易用的开源 ORM 框架,支持.NET CORE 和 MySql、SqlServer、Sqlite、Oracle 、 postgresql 、达梦、人大金仓 数据库,具有 EF NH 的功能,比 EF 更人性化的语法,支持真实的批量操作,另外还有媲美 DAPPER 的性能。
开源地址:dotNET China/SqlSugar ORM
文档地址:http://donet5.com/Home/Doc
安装SqlSugarCore包
项目结构
connectionString 解释
Data Source 数据库地址
Database 数据库名字
User Id 登录用户名
Password 密码
charset 文字编码
port 端口号
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using DbType = SqlSugar.DbType;
namespace WXCode.DB
{
public class SqlSugarConfig
{
private static readonly string connectionString = "Data Source=xx.xx.xx.xx;Database=test_db;User Id='testuser';Password='aacccsshgdjw123';charset=utf8;port=3306";
public static SqlSugarClient GetInstance()
{
var db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = connectionString,
DbType = DbType.MySql,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
});
return db;
}
}
}
App.xaml.cs
using Microsoft.Data.SqlClient.Server;
using Microsoft.Data.Sqlite;
using Prism.Ioc;
using SqlSugar;
using System;
using System.Windows;
using WXCode.DB;
using WXCode.Views;
namespace WXCode
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
protected override Window CreateShell()
{
return Container.Resolve<MainWindow>();
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
/// 注入SqlSugarClient对象
containerRegistry.RegisterSingleton<SqlSugarClient>(()=>SqlSugarConfig.GetInstance());
}
}
}
using Prism.Ioc;
using Prism.Modularity;
using SqlSugar;
using System.Collections.Generic;
using System;
using System.Windows;
using WXCode.DB;
namespace WXCode.Views
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private SqlSugarClient _sqlSugarClient;
public MainWindow(IContainerExtension container, SqlSugarClient sqlSugarClient)
{
InitializeComponent();
this._sqlSugarClient = sqlSugarClient;
int count = _sqlSugarClient.Ado.GetInt("select count(*) from user");
MessageBox.Show("查询数量:"+ count, "MainWindow");
}
}
}
运行效果
文章浏览阅读1w次。本文介绍了UOS系统安装(全盘安装)的过程,如果没有特殊要求,推荐安装UOS系统都采用全盘安装_统信uos系统专业版
文章浏览阅读116次。这种专利有意思吗 有意义吗 有创新吗?和别人都是右手写字,我申请左手写字的专利 ,,有什么区别
文章浏览阅读514次。jmeter接口测试自动获取cookie有时候我们接口地址和方式都对,就是报错,查看接口文档,其实需要加上消息头cookie,添加完cookie,不需要配置获取什么的,只要加一个访问网站的首页地址(HTTP请求),他会自动获取到cookie值添加cookie管理器加完cookie管理器,登录里就获取到了cookie值Jmeter请求参数3种形..._jmeter request body获取cookie
文章浏览阅读413次。编辑距离用于计算序列之间编辑距离和对齐的python模块。我需要一种方法来计算python中序列之间的编辑距离。我没有能够找到任何合适的库来实现这一点,所以我自己编写了一个。在那里似乎有许多可用于计算编辑的编辑距离库两个字符串之间的距离,但不是两个序列之间的距离。这完全是用python编写的。这种实现可能是在python中优化为更快。如果在C中实现。库API是根据difflib.sequencem..._edit distance python lib
文章浏览阅读3.8k次,点赞2次,收藏15次。antd 的upload组件是点开对话框后,按下确实就会上传,而且如果多选文件也会反复调用后端接口来完成上传。因为项目需要,所以要实现手动上传,和一次性上传多个文件(调用一次后端接口)在实现这个功能时,我翻阅了很多博客,可能是因为版本原因,很多代码都无用,最后还是通过翻阅官方文档,才最终实现。..._antd upload
文章浏览阅读246次。注意 第一步在一个文件下打开终端然后 sqlite3 student.db(创建一个数据库),然后再create stu。callback 回调函数 (只有sql为查询语句的时候,才会执行此语句)6--删除一列(sqlite3 不支持) 用下面方法。功能 :打开sqlite 数据库。功能 :关闭sqlite 数据库。基本sql命令,不以 . 夹头,db:指向sqlite句柄的指针。将新表的名字改为原来表的名字。sqlite3的基本命令。功能:执行一条sql语句。以 . 开头的命令。_sqlite 部署
文章浏览阅读1.5k次。windowns以及linux下的内存泄露方法实现_clion 内存泄漏
文章浏览阅读3.1k次。练习内容:给出上图拓扑图,配置两个交换机后,使得pc14可直接ping通pc17 ,给定各pc的ip和掩码如下pc14: 192.168.0.1 255.255.255.0 pc15: 192.168.0.2 255.255.255.0pc16: 192.168.0.3 255.255.255.0 pc17: 192.168.0.4 255.255.25..._适合练习用的华为交换机
文章浏览阅读640次,点赞8次,收藏11次。java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoa解决方案_java.lang.classnotfoundexception: org.springframework.web.context.contextloa
文章浏览阅读1.4w次,点赞9次,收藏10次。Autodesk卸载工具是一个专门用于Autodesk软件的卸载工具,可以自动识别电脑中的所有Autodesk软件,只需一键点击就能将Autodesk的软件完美卸载,并且不保留任何痕迹,这款卸载工具就可以帮助用户全面卸载Autodesk软件。_autodesk官方卸载工具
文章浏览阅读4.9k次。1.配置书写错误:配置文件value值引号内不能有空格,属性文件配置信息末尾不能有空格(1)打开属性文件中com.mysql.jdbc.Driver后发现多了一个空格(如下我标出了),所以写属性文件时一定别多输入多余的空格了。 jdbc.driverClassName=com.mysql.jdbc.Driver(此处有空格)(2)配置文件中的value值的" "号中前面或..._cannot find class: com.mysql.jdbc.driver
文章浏览阅读1.8k次。软件常用术语,免得你面对各种设计模式头发晕_软件术语