mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-05 07:50:52 +08:00
update
@@ -45,10 +45,19 @@ FreeSql 支持五种数据库,分别为 MySql/SqlServer/PostgreSQL/Oracle/Sqli
|
|||||||
|
|
||||||
比如 SqlServer 提供的 output inserted 特性,在表使用了自增或数据库定义了默认值的时候,使用它可以快速将 insert 的数据返回。PostgreSQL 也有相应的功能,如此方便却不是每个数据库都支持。
|
比如 SqlServer 提供的 output inserted 特性,在表使用了自增或数据库定义了默认值的时候,使用它可以快速将 insert 的数据返回。PostgreSQL 也有相应的功能,如此方便却不是每个数据库都支持。
|
||||||
|
|
||||||
|
IRepository 接口定义:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
TEntity Insert(TEntity entity);
|
||||||
|
Task<TEntity> InsertAsync(TEntity entity);
|
||||||
|
```
|
||||||
|
|
||||||
|
于是我们现实了两种仓库层实现:
|
||||||
|
|
||||||
- BaseRepository 采用了 ExecuteInserted 执行;
|
- BaseRepository 采用了 ExecuteInserted 执行;
|
||||||
- GuidRepository 采用了 ExecuteAffrows 执行(兼容性好);
|
- GuidRepository 采用了 ExecuteAffrows 执行(兼容性好);
|
||||||
|
|
||||||
当采用了不支持的数据库时(Sqlite/MySql/Oracle),建议如下:
|
当采用了不支持的数据库时(Sqlite/MySql/Oracle),建议:
|
||||||
|
|
||||||
* 使用 uuid 作为主键(即 Guid);
|
* 使用 uuid 作为主键(即 Guid);
|
||||||
* 避免使用数据库的默认值功能;
|
* 避免使用数据库的默认值功能;
|
||||||
|
|||||||
Reference in New Issue
Block a user