Skip to content

Commit 7be9834

Browse files
committed
修复 dyrepository/intro.md 代码错位
1 parent 0610dfa commit 7be9834

File tree

4 files changed

+28
-57
lines changed

4 files changed

+28
-57
lines changed

book.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
},
1313
"plugins": [
14-
"prism","prism-themes", "-highlight", "github", "github-buttons", "anchor-navigation-ex", "copy-code-button", "rss", "favicon", "ga"
14+
"prism", "prism-themes", "-highlight", "github", "github-buttons", "anchor-navigation-ex", "copy-code-button", "rss", "favicon", "ga"
1515
],
1616
"pluginsConfig": {
1717
"prism": {
@@ -41,10 +41,6 @@
4141
"type": "star",
4242
"size": "small",
4343
"count": true
44-
}, {
45-
"user": "Ahoo-Wang",
46-
"type": "follow",
47-
"size": "small"
4844
}]
4945
},
5046
"anchor-navigation-ex": {

dyrepository/intro.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ DyRepository可以将任意一个接口实现出查询数据库的工具,CURD
2727
### 准备工作
2828

2929
1. 先创建一个仓储,这个仓储不依赖SmartSql,只是普普通通的仓储接口
30-
```cs
30+
31+
``` csharp
3132
//仓储接口,默认模版是I{Scope}Repository,所以这个接口的Scope是Activity
3233
public interface IActivityRepository
3334
{
@@ -38,7 +39,6 @@ DyRepository可以将任意一个接口实现出查询数据库的工具,CURD
3839
//值类型的参数会自动封装为一个对象,所以这个方法的Request是new { activityId = activityId }
3940
Activity Query(long activityId);
4041
}
41-
4242
```
4343

4444
2. 创建配置xml文件SmartSqlMapConfig.xml:
@@ -100,7 +100,7 @@ DyRepository可以将任意一个接口实现出查询数据库的工具,CURD
100100

101101
如果不用DyRepository,我们需要用ISmartSqlMapper实现这个仓储。
102102

103-
```cs
103+
``` csharp
104104

105105
public class ActivityRepository : IActivityRepository
106106
{
@@ -127,9 +127,10 @@ DyRepository可以将任意一个接口实现出查询数据库的工具,CURD
127127
}
128128
}
129129
```
130+
130131
再把实现类注册到IoC中:
131132

132-
```cs
133+
``` csharp
133134
var services = new ServiceCollection();
134135
var services.AddSingleton<IActivityRepository,ActivityRepository>();
135136
```
@@ -138,7 +139,7 @@ var services.AddSingleton<IActivityRepository,ActivityRepository>();
138139

139140
如果使用DyRepository,我们只需配置一下IoC注册即可。
140141

141-
```cs
142+
``` csharp
142143
var services = new ServiceCollection();
143144
services.AddSmartSqlRepositoryFromAssembly((options) =>
144145
{
@@ -150,7 +151,7 @@ var services.AddSingleton<IActivityRepository,ActivityRepository>();
150151

151152
使用方法就注入接口,再调用接口方法了。
152153

153-
```cs
154+
``` csharp
154155
// 假设ActivityService已经注册到IoC容器
155156
public class ActivityService
156157
{

dyrepository/options.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ DyRepository的配置分为默认配置、特性配置和注册配置,但是
99
## 必须的配置:
1010

1111
1. 单个注册
12-
```cs
12+
13+
``` csharp
1314
services.AddRepository<IUserRepository>();
1415
```
1516

1617
2. 批量注册
17-
```cs
18+
19+
``` csharp
1820
services.AddSmartSqlRepositoryFromAssembly((options) =>
1921
{
2022
//仓储接口所在程序集全名
@@ -35,7 +37,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
3537

3638
#### 特性配置
3739

38-
```cs
40+
``` csharp
3941
[SqlMap(Scope = "User")]
4042
public interface IUserDao
4143
{
@@ -44,7 +46,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
4446

4547
#### 注册配置
4648

47-
```cs
49+
``` csharp
4850
//接口还是那个接口
4951
public interface IUserDao
5052
{
@@ -70,7 +72,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
7072

7173
因为SmartSql的sql配置是可以动态渲染的,当同一个SqlId传入不同的参数,可以渲染出不同的查询条件。例如:
7274

73-
```xml
75+
``` xml
7476
<Statement Id="Query">
7577
SELECT * FROM User T
7678
<Where>
@@ -88,7 +90,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
8890

8991
#### 特性配置
9092

91-
```cs
93+
``` csharp
9294
[SqlMap(Scope = "User")]
9395
public interface IUserRepository
9496
{
@@ -104,7 +106,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
104106

105107
注册配置中是通过配置一个叫sqlIdNamingConvert的委托参数来实现接口方法名到SqlId的转换方法。
106108

107-
```cs
109+
``` csharp
108110
services.AddSmartSqlRepositoryFactory(sqlIdNamingConvert: (type, method) =>
109111
{
110112
if (method.Name.StartsWith("QueryBy"))
@@ -130,7 +132,7 @@ I{Scope}Repository是默认配置的Scope模版,如IUserRepository的Scope就
130132

131133
即直接给接口方法绑定sql,无需再从xml中配置sql了,但请注意参数前缀还是需要在对应的配置文件配置。
132134

133-
```cs
135+
``` csharp
134136
[Statement(Sql = "Select Top(@taken) T.* From User T With(NoLock);")]
135137
IEnumerable<User> QueryBySql(int taken);
136138
```
@@ -148,7 +150,7 @@ Statement特性只标记在方法上,还有其他几个参数:
148150

149151
即把接口方法的参数值传递给Sql渲染时指定参数名的参数,例如把id的值传递给@UserId
150152

151-
```cs
153+
``` csharp
152154
IEnumerable<User> Query([Param("UserId")]int id);
153155
```
154156

guide/installation.md

+9-37
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
11
# 安装
22

3-
## 安装 SmartSql
4-
5-
``` chsarp
6-
Install-Package SmartSql
7-
```
8-
9-
## 安装 SmartSql.DyRepository
10-
11-
``` chsarp
12-
Install-Package SmartSql.DyRepository
13-
```
14-
15-
## 安装 SmartSql.DIExtension [For DI]
16-
17-
``` chsarp
18-
Install-Package SmartSql.DIExtension
19-
```
20-
21-
## 安装 SmartSql.Cache.Redis
22-
23-
``` chsarp
24-
Install-Package SmartSql.Cache.Redis
25-
```
26-
27-
## 安装 SmartSql.ZooKeeperConfig
28-
29-
``` chsarp
30-
Install-Package SmartSql.ZooKeeperConfig
31-
```
32-
33-
## 安装 SmartSql.TypeHandler
34-
35-
``` chsarp
36-
Install-Package SmartSql.TypeHandler
37-
```
38-
393
## 安装 XML Schema File 文件获得智能提示
404

415
下载以下俩个文件至 Microsoft Visual Studio XSD安装目录
@@ -47,4 +11,12 @@ VS2017目录地址:\Microsoft Visual Studio\2017\Enterprise\Xml\Schemas
4711
| 文件 | 地址 |
4812
| -------- | -----: |
4913
| SmartSqlMapConfig.xsd | [SmartSqlMapConfig.xsd](https://raw.githubusercontent.com/Ahoo-Wang/SmartSql/master/doc/Schemas/SmartSqlMapConfig.xsd) |
50-
| SmartSqlMap.xsd | [SmartSqlMap.xsd](https://raw.githubusercontent.com/Ahoo-Wang/SmartSql/master/doc/Schemas/SmartSqlMap.xsd) |
14+
| SmartSqlMap.xsd | [SmartSqlMap.xsd](https://raw.githubusercontent.com/Ahoo-Wang/SmartSql/master/doc/Schemas/SmartSqlMap.xsd) |
15+
16+
## 安装 SmartSql
17+
18+
``` chsarp
19+
Install-Package SmartSql
20+
```
21+
22+
##

0 commit comments

Comments
 (0)