什么是AOP?这种在运行时,动态地将代码切入到类的指定方法、指定位置上的编程思想就是面向切面的编程。
什么是AOP?这种在运行时,动态地将代码切入到类的指定方法、指定位置上的编程思想就是面向切面的编程。
什么是AOP?这种在运行时,动态地将代码切入到类的指定方法、指定位置上的编程思想就是面向切面的编程。
I had written the following code in a project
...
return s && s.value || null
It works well for some days until a colleague did some code refactoring. In the beginning, s.value is a string value, and an empty string is not a valid value, so the code works well. After the refactoring, s.value became an integer, and this time 0
is a valid value. So you can imagine when s.value === 0
the code above will return null instead of 0. It leads to a bug!
Therefore please use the"A || B
" expression with caution!
Two articles explain well this subject. One is in Chinese, the other is in English.
StartUp.cs
, add the highlight part below:services.AddMemoryCache().AddMvcCore().AddJsonOptions(opts => { opts.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }) .AddDataAnnotationsLocalization();
Enable XML Comments
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
2. Add the options in the code below
services.AddSwaggerGen(options =>
{
options.IncludeXmlComments(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{AppDomain.CurrentDomain.FriendlyName}.xml"), true);
});
await Db.Queryable<Entity>().Where(_ => _.SampleFieldName== sampleFieldValue)
.GroupBy("AnothterFieldNameInStringFormat")
.Select<ResultModel>("AnotherFieldNameInStringFormat, Count(AnotherFieldNameInStringFormat) Total")
.ToListAsync();