Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/2881099/FreeSql.Connection.Extensions
Mysql, postgresql, sqlserver, Oracle and SQLite connection object extension methods.
https://github.com/2881099/FreeSql.Connection.Extensions
dapper dbconnection freesql orm sqlhelper
Last synced: about 2 months ago
JSON representation
Mysql, postgresql, sqlserver, Oracle and SQLite connection object extension methods.
- Host: GitHub
- URL: https://github.com/2881099/FreeSql.Connection.Extensions
- Owner: 2881099
- License: mit
- Created: 2019-04-10T14:40:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T20:45:36.000Z (over 4 years ago)
- Last Synced: 2024-11-07T03:18:48.217Z (about 2 months ago)
- Topics: dapper, dbconnection, freesql, orm, sqlhelper
- Language: C#
- Homepage:
- Size: 26.4 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
## 提示:该功能库不再维护,CRUD 扩展方法已转移至 FreeSql.dll v1.8.0 中,为了与 Dapper.Query 不冲突已移除 Query 扩展方法。
这是 [FreeSql](https://github.com/2881099/FreeSql) 衍生出来的扩展包,实现(Mysql/postgresql/sqlserver/Oracle/SQLite)数据库连接对象扩展方法,像 Dapper 一样的使用习惯(QQ群:4336577)。
> dotnet add package FreeSql.Connection.Extensions
## 更新日志
- 增加 数据库对象.Select 方法;
- 增加 数据库对象.Update 方法;
- 增加 数据库对象.Insert 方法;
- 增加 数据库对象.Delete 方法;
- 增加 数据库对象.Query 执行 SQL 语句的查询方法;## 快速开始
### 测试实体类
```csharp
class TestConnectionExt {
public Guid id { get; set; }
public string title { get; set; }
public DateTime createTime { get; set; } = DateTime.Now;public List Details { get; set; }
}
class Detail {
public Guid id { get; set; }public Guid ParentId { get; set; }
public DateTime createTime { get; set; } = DateTime.Now;
}
```### 查询
```csharp
using (var conn = new MySqlConnection(_connectString)) {
var list = conn.Select()
.Where(a => a.id == item.id)
.IncludeMany(a => a.Details.Where(b => b.ParentId == a.id))
.ToList();
}
```
更多前往Wiki:[《Select 查询数据文档》](https://github.com/2881099/FreeSql/wiki/%e6%9f%a5%e8%af%a2)### 插入
```csharp
using (var conn = new MySqlConnection(_connectString)) {
var item = new TestConnectionExt { title = "testinsert" };
var affrows = conn.Insert().AppendData(item).ExecuteAffrows();
}
```
更多前往Wiki:[《Insert 插入数据文档》](https://github.com/2881099/FreeSql/wiki/%e6%b7%bb%e5%8a%a0)### 更新
```csharp
using (var conn = new MySqlConnection(_connectString)) {
var affrows = conn.Update()
.Where(a => a.Id == xxx)
.Set(a => a.title, "testupdated")
.ExecuteAffrows();
}
```
更多前往Wiki:[《Update 更新数据文档》](https://github.com/2881099/FreeSql/wiki/%e4%bf%ae%e6%94%b9)### 删除
```csharp
using (var conn = new MySqlConnection(_connectString)) {
var affrows = conn.Delete()
.Where(a => a.Id == xxx)
.ExecuteAffrows();
}
```
更多前往Wiki:[《Delete 删除数据文档》](https://github.com/2881099/FreeSql/wiki/%e5%88%a0%e9%99%a4)### 事务
就像 ado.net 那样使用即可。