Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:修改代码块注释c#为csharp #19

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/03.NET微服务/02.ORM/03.FreeSql.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var user = fsql.Select<User>().Where(u => u.Name == "张三").FirstOrDefault();

#### 查询where条件

```c#
```csharp
var blogslist1 = fsql.Select<Blog>()
.Where( b => b.Rating > -3 )
.OrderBy( b => b.Url )
Expand All @@ -92,7 +92,7 @@ var blogslist2 = fsql.Select<Blog>()

Where可以写多个,实际是多个and条件

```c#
```
var blogslist1 = fsql.Select<Blog>()
.Where( b => b.Rating > -3 )
.Where ( b=>b.BlogId >50 )
Expand All @@ -104,7 +104,7 @@ var blogslist1 = fsql.Select<Blog>()

#### 查询WhereIf条件

```c#
```csharp
var blogslist3 = fsql.Select<Blog>()
.Where( "BlogId>=@min and BlogId<=@max" , new
{
Expand All @@ -126,7 +126,7 @@ var blogslist3 = fsql.Select<Blog>()

##### in查询

```c#
```csharp
//数字类型
var list1 = DB.fsql.Select<Blog>()
.Where( a => new[] { 1 , 2 , 3 }.Contains( a.Rating ) )
Expand Down Expand Up @@ -165,7 +165,7 @@ var list = fsql.Select<SPIBOARDBINDS>()

##### in子表查询

```c#
```csharp
//in子表查询
var list3 = DB.fsql.Select<Blog>()
.Where( it => it.BlogId >= 1 )
Expand Down Expand Up @@ -214,7 +214,7 @@ fsql.Insert(user).ExecuteAffrows();

##### 单个插入

```c#
```csharp
var ids = fsql.Insert( bill ).ExecuteAffrows();

//执行SQL语句,返回影响的行数
Expand All @@ -241,7 +241,7 @@ List<Blog> list1 = DBClass.fsql.Insert( new Blog()

##### 批量插入

```c#
```csharp
//执行SQL语句,返回影响的行数
int i1 = fsql.Insert( new List<Blog>() {
new Blog() { Rating = 1 , Url = "rul" },
Expand Down Expand Up @@ -273,7 +273,7 @@ new Blog() {

##### 获取自动增长ID

```c#
```csharp
//ExecuteIdentity 返回标识列
long ids = DBClass.fsql.Insert( new Blog()
{
Expand All @@ -288,7 +288,7 @@ long ids = DBClass.fsql.Insert( new Blog()

##### 主从表插入

```c#
```csharp
DateTime now = DateTime.Now;

//返回标识列
Expand Down Expand Up @@ -326,7 +326,7 @@ var list2 = DBClass.fsql.Insert( new List<users>() {

##### 插入指定列和忽略列

```c#
```csharp
//插入指定的列 InsertColumns
long ids2 = DBClass.fsql.Insert( new Blog()
{
Expand Down Expand Up @@ -359,7 +359,7 @@ long ids3 = DBClass.fsql.Insert( new Blog()

##### 字典插入

```c#
```csharp
var dic = new Dictionary<string , object>();
dic.Add( "Rating" , 1 );
dic.Add( "Times" , DateTime.Now );
Expand Down
12 changes: 6 additions & 6 deletions docs/03.NET微服务/03.任务调度/02.Quartz.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);

> 1.传递键值参数 2.利用JobDataMap可以传递对象类型数据

```c#
```csharp
//这里演示了2种传递参数的方式:1种是JobDataMap(如果需要传递对象,可以这样做),1种是键值
IJobDetail job4 = JobBuilder.Create<RunClassA>().WithIdentity( "Job4" , "JobGroup4" )
.UsingJobData( getMyData() )
Expand All @@ -306,7 +306,7 @@ job4.JobDataMap.Add( "my4" , "123qq" );
job4.JobDataMap.Add( "my5" , true );
```

```c#
```csharp
/// <summary>
/// 返回JobDataMap,传递类
/// </summary>
Expand Down Expand Up @@ -337,7 +337,7 @@ JobDataMap getMyData ()

> Trigger中传递参数的方式和job中是一样的

```c#
```csharp
ITrigger trigger4 = TriggerBuilder.Create().WithIdentity( "_Trigger4" , "TGroup4" )
.WithCronSchedule( cron_4 )
//在Trigger中也可以传递参数的
Expand All @@ -354,7 +354,7 @@ trigger4.JobDataMap.Add("t2",123);

##### 1.接收Job传递参数

```c#
```csharp
//接收传递过来参数
JobDataMap dataMap = context.JobDetail.JobDataMap;

Expand All @@ -371,7 +371,7 @@ MyClass my2Data = ( MyClass ) dataMap.Get( "my2" );

##### 2.接收Trigger传递参数

```c#
```csharp
//接收Trigger中传递参数
JobDataMap triJobDataMap = context.Trigger.JobDataMap;
var val = triJobDataMap.GetString( "t1" );
Expand All @@ -388,7 +388,7 @@ int t2 = triJobDataMap.GetInt( "t2" );
>
> DisallowConcurrentExecution特性是禁止相同JobDetail同时执行,也就是禁止并行任务,必须任务一个个进行(串行的)

```c#
```csharp
[DisallowConcurrentExecution]
[PersistJobDataAfterExecution]
public class RunClassB : Quartz.IJob
Expand Down
10 changes: 5 additions & 5 deletions docs/03.NET微服务/04.日志/01.Serilog.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class Program

##### 写入变量

```c#
```csharp
var itemNumber = 10;
var itemCount = 999;

Expand All @@ -232,7 +232,7 @@ this._logger.LogDebug( "Processing item {ItemNumber} of {ItemCount}" , itemNumbe
> 1.日志中会多一个$type属性
> 2.日期类型数据格式化后都是这样格式:2023-09-16T22:26:27.5905512+08:00

```c#
```csharp
var wf = new WeatherForecast
{
Date = DateTime.Now.AddDays( 1 ) ,
Expand All @@ -251,14 +251,14 @@ this._logger.LogInformation( "WeatherForecast 的数据 {@wf}" , wf );

##### 写入集合

```c#
```csharp
List<string> list1 = new List<string>() { "q1" , "q2" };

//写入集合
//结果:2023-09-15 22:36:46.751 +08:00 [INF] 集合的数据 ["q1","q2"]
this._logger.LogInformation( "集合的数据 {@list1}" , list1 );
```
```c#
```csharp
List<WeatherForecast> listw = new List<WeatherForecast>() {
new WeatherForecast
{
Expand All @@ -281,7 +281,7 @@ this._logger.LogInformation( "集合的数据 {@listw}" , listw );

##### 写入匿名类

```c#
```csharp
var user = new
{
Name = "Nick" ,
Expand Down
20 changes: 10 additions & 10 deletions docs/03.NET微服务/08.消息传递/01.MediatR.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public class OrdersController : ControllerBase
>
> 模型一般用XXXCommand命名

```c#
```csharp
//定义模型
//实现IRequest,返回布尔值
public record CreateCustomerCommand (
Expand All @@ -235,7 +235,7 @@ public record CreateCustomerCommand (
>
> 一般用xxxHandler命名

```c#
```csharp
/*
消费者,实现接口IRequestHandler <>中第1个传递参数的类型,第2个是返回数据类型
*/
Expand Down Expand Up @@ -264,7 +264,7 @@ public record CreateCustomerCommand (

###### 3.生产者(发送请求)

```c#
```csharp
CreateCustomerCommand createCustomerCommand = new CreateCustomerCommand( "q" , "h" );

bool result = await this.mediator.Send( createCustomerCommand );
Expand All @@ -276,7 +276,7 @@ bool result = await this.mediator.Send( createCustomerCommand );

###### 1.定义传递模型

```c#
```csharp
//定义模型
//实现IRequest, 这种无返回值

Expand All @@ -288,7 +288,7 @@ public record CreatePingCommand (

###### 2.实现消息者

```c#
```csharp
/*
消费者,实现接口IRequestHandler <>中第1个传递参数的类型 ,这种无返回值
*/
Expand Down Expand Up @@ -317,7 +317,7 @@ public record CreatePingCommand (

###### 3.生产者(发送请求)

```c#
```csharp
CreatePingCommand _Command = new CreatePingCommand( "q" , "hmz" );

// 没有返回值
Expand All @@ -334,7 +334,7 @@ await this.mediator.Send( _Command );
>
> 模型一般用XXXEvent命名

```c#
```csharp
//继承接口,消息传递类

public record CustomerCreatedEvent (
Expand All @@ -353,7 +353,7 @@ public record CustomerCreatedEvent (

第1个消费者

```c#
```csharp
/*
消费者,实现接口INotificationHandler <>中第1个传递参数的类型
*/
Expand Down Expand Up @@ -381,7 +381,7 @@ public record CustomerCreatedEvent (

第2个消费者

```c#
```csharp
public class CustomerCreatedLoggerHandler : INotificationHandler<CustomerCreatedEvent>
{
private readonly ILogger<CustomerCreatedLoggerHandler> _logger;
Expand All @@ -406,7 +406,7 @@ public record CustomerCreatedEvent (

##### 3.生产者(发送请求)

```c#
```csharp
CustomerCreatedEvent _Command = new CustomerCreatedEvent( "q" , "hmz" , DateTime.Now );

// Publish发布消息
Expand Down
10 changes: 5 additions & 5 deletions docs/03.NET微服务/09.熔断重试限流/01.Polly.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ retryPolicy.Execute(() =>

##### 设置重试次数

```c#
```csharp
//Retry(3) 重试3次
var _Policy = Policy.Handle<Exception>() // 定义条件
.Retry( 3 , ( exception , retryCount ) =>
Expand All @@ -84,7 +84,7 @@ _Policy.Execute( () =>

##### 无限重试,直到成功

```c#
```csharp
// 不断重试,直到成功 RetryForever
var _Policy = Policy.Handle<Exception>() // 定义条件
.RetryForever( ( exception , retryCount ) =>
Expand All @@ -111,7 +111,7 @@ _Policy.Execute( () =>

##### 等待重试,每次间隔时间

```c#
```csharp
//失败后第一次重试等待1秒,第2次等待2秒,第3次等待5秒,第4次等待1秒,
//重试4次,分别等待1、2、5,1秒。
var _Policy = Policy.Handle<Exception>() // 定义条件
Expand All @@ -134,7 +134,7 @@ var _Policy = Policy.Handle<Exception>() // 定义条件

另一种模式

```c#
```csharp
// 重试5次,每次间隔2秒
var _Policy = Policy.Handle<Exception>() // 定义条件
.WaitAndRetry( 5 ,
Expand All @@ -154,7 +154,7 @@ var _Policy = Policy.Handle<Exception>() // 定义条件

##### 等待重试,每次间隔时间,直到成功

```c#
```csharp
var _Policy = Policy.Handle<Exception>() // 定义条件
.WaitAndRetryForever(
retryAttempt => TimeSpan.FromSeconds( 2 ) ,
Expand Down
4 changes: 2 additions & 2 deletions docs/03.NET微服务/10.缓存/07.Memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cache.Remove("key");

这2个方法,都可以在获取数据的同时进行进行判断,如果cache不存在同时进行添加

```c#
```csharp
//GetOrCreate第一个参数是cache名称,第2个参数是Func委托,当cache不存在时就会运行创建
string val1 = memoryCache.GetOrCreate<string>("my1", entry =>
{
Expand All @@ -107,7 +107,7 @@ if (val1 != null)



```c#
```csharp
string cachename = "tbdata";

List<WeatherForecast> tb = null;
Expand Down