@@ -10,38 +10,17 @@ description : 拥抱 跨平台 DotNet Core,是时候了。高性能、高生
10
10
11
11
# 简介
12
12
13
- [ ![ Join the chat at https://gitter.im/SmartSql-DotNet/Lobby ] ( https://badges.gitter.im/SmartSql-DotNet/Lobby.svg )] ( https://gitter.im/SmartSql-DotNet/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge )
14
-
15
- > [ SmartSql-Starter] ( https://github.com/Ahoo-Wang/SmartSql-Starter )
16
-
17
-
18
-
19
- ## Nuget Packages
20
-
21
- | Package | NuGet Stable | Downloads |
22
- | ------- | -------- | ------- |
23
- | [ SmartSql] ( https://www.nuget.org/packages/SmartSql/ ) | [ ![ SmartSql] ( https://img.shields.io/nuget/v/SmartSql.svg )] ( https://www.nuget.org/packages/SmartSql/ ) | [ ![ SmartSql] ( https://img.shields.io/nuget/dt/SmartSql.svg )] ( https://www.nuget.org/packages/SmartSql/ ) |
24
- | [ SmartSql.TypeHandler] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) | [ ![ SmartSql.TypeHandler] ( https://img.shields.io/nuget/v/SmartSql.TypeHandler.svg )] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) | [ ![ SmartSql.TypeHandler] ( https://img.shields.io/nuget/dt/SmartSql.TypeHandler.svg )] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) |
25
- | [ SmartSql.DyRepository] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) | [ ![ SmartSql.DyRepository] ( https://img.shields.io/nuget/v/SmartSql.DyRepository.svg )] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) | [ ![ SmartSql.DyRepository] ( https://img.shields.io/nuget/dt/SmartSql.DyRepository.svg )] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) |
26
- | [ SmartSql.DIExtension] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) | [ ![ SmartSql.DIExtension] ( https://img.shields.io/nuget/v/SmartSql.DIExtension.svg )] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) | [ ![ SmartSql.DIExtension] ( https://img.shields.io/nuget/dt/SmartSql.DIExtension.svg )] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) |
27
- | [ SmartSql.Cache.Redis] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) | [ ![ SmartSql.Cache.Redis] ( https://img.shields.io/nuget/v/SmartSql.Cache.Redis.svg )] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) | [ ![ SmartSql.Cache.Redis] ( https://img.shields.io/nuget/dt/SmartSql.Cache.Redis.svg )] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) |
28
- | [ SmartSql.ZooKeeperConfig] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) | [ ![ SmartSql.ZooKeeperConfig] ( https://img.shields.io/nuget/v/SmartSql.ZooKeeperConfig.svg )] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) | [ ![ SmartSql.ZooKeeperConfig] ( https://img.shields.io/nuget/dt/SmartSql.ZooKeeperConfig.svg )] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) |
29
-
30
- ## 0. Why
13
+ ## Why
31
14
32
15
- 拥抱 跨平台 DotNet Core,是时候了。
33
- - 高性能、高生产力,超轻量级的ORM。** 107kb **
16
+ - 高性能、高生产力,超轻量级的ORM。** 156kb ** (Dapper: ** 168kb ** )
34
17
35
- ---
36
-
37
- ## 1. So SmartSql
18
+ ## So SmartSql
38
19
39
20
- TargetFrameworks: .NETFramework 4.6 & .NETStandard 2.0
40
21
- SmartSql = SmartSql = MyBatis + Cache(Memory | Redis) + ZooKeeper + R/W Splitting +Dynamic Repository + ......
41
22
42
- ---
43
-
44
- ## 2. 主要特性
23
+ ## 主要特性
45
24
46
25
- 1 ORM
47
26
- 1.1 Sync
@@ -69,9 +48,7 @@ description : 拥抱 跨平台 DotNet Core,是时候了。高性能、高生
69
48
- 7.3.1 Load SmartSqlMapSource Directory
70
49
- 7.3 SmartSql.ZooKeeperConfig (ZooKeeper 分布式配置文件加载器)
71
50
72
- ---
73
-
74
- ## 3. 性能评测
51
+ ## 性能评测
75
52
76
53
``` ini
77
54
@@ -98,140 +75,35 @@ Intel Core i7-6700K CPU 4.00GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
98
75
99
76
---
100
77
101
- ## 4. 安装 (NuGet)
102
-
103
- ``` csharp
104
- Install - Package SmartSql
105
- ```
106
-
107
- ## 5. 常规代码
108
-
109
- ### 查询
110
-
111
- ``` csharp
112
- ISmartSqlMapper SqlMapper = MapperContainer .Instance .GetSqlMapper ();
113
- SqlMapper .Query <T_Test >(new RequestContext
114
- {
115
- Scope = " T_Test" ,
116
- SqlId = " GetList" ,
117
- Request = new { Ids = new long [] { 1 , 2 , 3 , 4 } }
118
- });
119
- ```
120
-
121
- ### 事务
122
-
123
- ``` csharp
124
- try
125
- {
126
- ISmartSqlMapper SqlMapper = MapperContainer .Instance .GetSqlMapper ();
127
- SqlMapper .BeginTransaction ();
128
- // BizCode
129
- SqlMapper .CommitTransaction ();
130
- }
131
- catch (Exception ex )
132
- {
133
- SqlMapper .RollbackTransaction ();
134
- throw ex ;
135
- }
136
- ```
137
-
138
- ## 6. 最佳实践
139
-
140
- ### 6.1 安装 SmartSql.DIExtension
141
-
142
- ``` chsarp
143
- Install-Package SmartSql.DIExtension
144
- ```
145
-
146
- ### 6.2 注入依赖
78
+ ## Nuget Packages
147
79
148
- ``` csharp
149
- services .AddSmartSql ();
150
- services .AddRepositoryFactory ();
151
- services .AddRepositoryFromAssembly ((options ) =>
152
- {
153
- options .AssemblyString = " SmartSql.Starter.Repository" ;// 仓储接口项目
154
- });
155
- ```
80
+ | Package | NuGet Stable | Downloads |
81
+ | ------- | -------- | ------- |
82
+ | [ SmartSql] ( https://www.nuget.org/packages/SmartSql/ ) | [ ![ SmartSql] ( https://img.shields.io/nuget/v/SmartSql.svg )] ( https://www.nuget.org/packages/SmartSql/ ) | [ ![ SmartSql] ( https://img.shields.io/nuget/dt/SmartSql.svg )] ( https://www.nuget.org/packages/SmartSql/ ) |
83
+ | [ SmartSql.TypeHandler] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) | [ ![ SmartSql.TypeHandler] ( https://img.shields.io/nuget/v/SmartSql.TypeHandler.svg )] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) | [ ![ SmartSql.TypeHandler] ( https://img.shields.io/nuget/dt/SmartSql.TypeHandler.svg )] ( https://www.nuget.org/packages/SmartSql.TypeHandler/ ) |
84
+ | [ SmartSql.DyRepository] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) | [ ![ SmartSql.DyRepository] ( https://img.shields.io/nuget/v/SmartSql.DyRepository.svg )] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) | [ ![ SmartSql.DyRepository] ( https://img.shields.io/nuget/dt/SmartSql.DyRepository.svg )] ( https://www.nuget.org/packages/SmartSql.DyRepository/ ) |
85
+ | [ SmartSql.DIExtension] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) | [ ![ SmartSql.DIExtension] ( https://img.shields.io/nuget/v/SmartSql.DIExtension.svg )] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) | [ ![ SmartSql.DIExtension] ( https://img.shields.io/nuget/dt/SmartSql.DIExtension.svg )] ( https://www.nuget.org/packages/SmartSql.DIExtension/ ) |
86
+ | [ SmartSql.Cache.Redis] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) | [ ![ SmartSql.Cache.Redis] ( https://img.shields.io/nuget/v/SmartSql.Cache.Redis.svg )] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) | [ ![ SmartSql.Cache.Redis] ( https://img.shields.io/nuget/dt/SmartSql.Cache.Redis.svg )] ( https://www.nuget.org/packages/SmartSql.Cache.Redis/ ) |
87
+ | [ SmartSql.ZooKeeperConfig] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) | [ ![ SmartSql.ZooKeeperConfig] ( https://img.shields.io/nuget/v/SmartSql.ZooKeeperConfig.svg )] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) | [ ![ SmartSql.ZooKeeperConfig] ( https://img.shields.io/nuget/dt/SmartSql.ZooKeeperConfig.svg )] ( https://www.nuget.org/packages/SmartSql.ZooKeeperConfig/ ) |
88
+ | [ SmartSql.Options] ( https://www.nuget.org/packages/SmartSql.Options/ ) | [ ![ SmartSql.Options] ( https://img.shields.io/nuget/v/SmartSql.Options.svg )] ( https://www.nuget.org/packages/SmartSql.Options/ ) | [ ![ SmartSql.Options] ( https://img.shields.io/nuget/dt/SmartSql.ZooKeeperConfig.svg )] ( https://www.nuget.org/packages/SmartSql.Options/ ) |
156
89
157
- ### 6.3 定义仓储接口
158
-
159
- ``` csharp
160
- /// <summary >
161
- /// 属性可选: [SqlMap(Scope = "User")] ,不设置 则默认 Scope 模板:I{Scope}Repository
162
- /// 可传入自定义模板
163
- /// RepositoryBuilder builder=new RepositoryBuilder("I{Scope}DAL");
164
- /// </summary >
165
- public interface IUserRepository : IRepository <User , string >
166
- {
167
- /// <summary >
168
- /// 属性可选 [Statement(Execute = ExecuteBehavior.Auto,Id = "Query")]
169
- /// 默认 Execute:Auto ,自动判断 执行类型
170
- /// 默认 Id : 方法名
171
- /// </summary >
172
- /// <param name =" reqParams" ></param >
173
- /// <returns ></returns >
174
- [Statement (Sql = " Select Top(@taken) T.* From User T With(NoLock);" )]
175
- IEnumerable <User > QueryBySql (int taken );
176
- }
177
- ```
90
+ ## 示例项目
178
91
179
- ### 6.4 尽情享用
180
-
181
- ``` csharp
182
- public class UserService
183
- {
184
- private readonly ITransaction _transaction ;
185
- private readonly IUserRepository _userRepository ;
186
-
187
- public UserService (
188
- ITransaction transaction
189
- , IUserRepository userRepository )
190
- {
191
- _transaction = transaction ;
192
- _userRepository = userRepository ;
193
- }
194
-
195
- public long Add (AddRequest request )
196
- {
197
- int existsNum = _userRepository .Exists (new { request .UserName });
198
- if (existsNum > 0 )
199
- {
200
- throw new ArgumentException ($" {nameof (request .UserName )} has already existed!" );
201
- }
202
- return _userRepository .Insert (new Entitiy .User
203
- {
204
- UserName = request .UserName ,
205
- Password = request .Password ,
206
- Status = Entitiy .UserStatus .Ok ,
207
- CreationTime = DateTime .Now ,
208
- });
209
- }
210
-
211
- public void UseTransaction ()
212
- {
213
- try
214
- {
215
- _transaction .BeginTransaction ();
216
- // Biz();
217
- _transaction .CommitTransaction ();
218
- }
219
- catch (Exception ex )
220
- {
221
- _transaction .RollbackTransaction ();
222
- throw ex ;
223
- }
224
- }
225
- }
226
- ```
92
+ > [ SmartSql-Starter] ( https://github.com/Ahoo-Wang/SmartSql-Starter )
227
93
228
- ## 7. 文档地址
94
+ ## 文档地址
229
95
230
96
- [ 在线阅读地址] ( https://doc.smartsql.net/ )
231
97
- [ PDF] ( https://www.gitbook.com/download/pdf/book/ahoo-wang/smartsql-doc-cn )
232
98
- [ Mobi] ( https://www.gitbook.com/download/mobi/book/ahoo-wang/smartsql-doc-cn )
233
99
- [ ePub] ( https://www.gitbook.com/download/epub/book/ahoo-wang/smartsql-doc-cn )
234
100
235
- ## 8. 技术交流
101
+ ## 文档贡献者
102
+
103
+ - [ Ahoo-Wang] ( https://github.com/Ahoo-Wang )
104
+ - [ RocherKong] ( https://github.com/RocherKong )
105
+ - [ ElderJames] ( https://github.com/ElderJames )
106
+
107
+ ## 技术交流
236
108
237
109
点击链接加入QQ群【SmartSql 官方交流群】:[ 604762592] ( https://jq.qq.com/?_wv=1027&k=5Sy8Ahw )
0 commit comments