9.13、其他操作

一些不常用的数据库操作,但又能解决很多奇葩的业务需求。

获取操作上下文

_testRepository.Context; // 返回 HoaDbContext 对象

获取DbSet 实体

_testRepository.Entity;

获取Database 操作对象

_testRepository.Database;

获取 EntityEntry 对象

_testRepository.EntityEntry(entity);

获取此对象可以操作 State 实体状态。

获取 EntityState 对象

_testRepository.EntityEntryState(entity);

获取 DbConnection 对象

解析连接字符串信息

数据库连接字符串

动态切换仓储表

输出EF Core 查询生成的 Sql 语句

提交更改

是否设置了主键Key

获取所有数据库上下文

将所有数据库上下文操作都保存

最后更新于

这有帮助吗?