<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: freecoderzhaoshuai</title>
    <description>The latest articles on DEV Community by freecoderzhaoshuai (@freecoderzhaoshuai).</description>
    <link>https://dev.to/freecoderzhaoshuai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F397693%2F152ab398-9e0c-401a-a34a-54963983d201.jpg</url>
      <title>DEV Community: freecoderzhaoshuai</title>
      <link>https://dev.to/freecoderzhaoshuai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/freecoderzhaoshuai"/>
    <language>en</language>
    <item>
      <title>Register ServiceBusClient in .net core web api</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Wed, 19 May 2021 07:07:13 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/register-servicebusclient-in-net-core-web-api-2bca</link>
      <guid>https://dev.to/freecoderzhaoshuai/register-servicebusclient-in-net-core-web-api-2bca</guid>
      <description>&lt;p&gt;services.AddHostedService();&lt;br&gt;
services.AddAzureClients(cfg =&amp;gt;&lt;br&gt;
{&lt;br&gt;
  cfg.AddServiceBusClient(Configuration.GetSection("ServiceBus")).WithCredential(new Azure.Identity.DefaultAzureCredential());&lt;br&gt;
});&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Choose if array element repeats itself twice — Javascript [duplicate]</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Fri, 31 Jul 2020 02:41:29 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/choose-if-array-element-repeats-itself-twice-javascript-duplicate-he0</link>
      <guid>https://dev.to/freecoderzhaoshuai/choose-if-array-element-repeats-itself-twice-javascript-duplicate-he0</guid>
      <description>&lt;p&gt;var arr  = [0, 1, 2, 2, 3, 3, 5];&lt;/p&gt;

&lt;p&gt;var dups = arr.filter ( (v,i,a) =&amp;gt; a.indexOf(v) &amp;lt; i );&lt;/p&gt;

&lt;p&gt;console.log(dups);&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
  2,&lt;br&gt;
  3&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;when v=2, a.indexof(2)=2,but i=3 &lt;br&gt;
so filter 2 to the dups&lt;/p&gt;

</description>
    </item>
    <item>
      <title>XmlAttributes.XmlIgnore Property</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Mon, 06 Jul 2020 14:25:53 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/xmlattributes-xmlignore-property-3hp6</link>
      <guid>https://dev.to/freecoderzhaoshuai/xmlattributes-xmlignore-property-3hp6</guid>
      <description>&lt;p&gt;using System;&lt;br&gt;
using System.IO;&lt;br&gt;
using System.Xml.Serialization;&lt;/p&gt;

&lt;p&gt;// This is the class that will be serialized.&lt;br&gt;
public class Group&lt;br&gt;
{&lt;br&gt;
   // The GroupName value will be serialized--unless it's overridden.&lt;br&gt;
   public string GroupName;&lt;/p&gt;

&lt;p&gt;/* This field will be ignored when serialized--&lt;br&gt;
      unless it's overridden. */&lt;br&gt;
   [XmlIgnoreAttribute]&lt;br&gt;
   public string Comment;&lt;br&gt;
}&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DotNet core code coverage</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Sat, 13 Jun 2020 14:34:18 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/dotnet-core-code-coverage-a17</link>
      <guid>https://dev.to/freecoderzhaoshuai/dotnet-core-code-coverage-a17</guid>
      <description>&lt;p&gt;You scanner begin should include the code coverage property&lt;/p&gt;

&lt;p&gt;dotnet sonarscanner begin /k:“project-key” /d:sonar.cs.vscoveragexml.reportsPaths=\TestResults*.coveragexml&lt;br&gt;
dotnet build my.sln&lt;br&gt;
dotnet test myTest.csproj --collect:“Code Coverage”&lt;br&gt;
powershell script to convert .coverage to coveragexml&lt;br&gt;
dotnet sonarscanner end&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Backup/Restore a dockerized PostgreSQL database</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Fri, 12 Jun 2020 02:46:52 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/backup-restore-a-dockerized-postgresql-database-2e3e</link>
      <guid>https://dev.to/freecoderzhaoshuai/backup-restore-a-dockerized-postgresql-database-2e3e</guid>
      <description>&lt;p&gt;Backup your databases&lt;br&gt;
docker exec -t your-db-container pg_dumpall -c -U postgres &amp;gt; dump_&lt;code&gt;date +%d-%m-%Y"_"%H_%M_%S&lt;/code&gt;.sql&lt;/p&gt;

&lt;p&gt;Restore your databases&lt;br&gt;
cat your_dump.sql | docker exec -i your-db-container psql -U postgres&lt;/p&gt;

</description>
    </item>
    <item>
      <title>which is faster to make a web api,python  or .net core?</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Thu, 11 Jun 2020 01:56:13 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/which-is-faster-to-make-a-web-api-python-or-net-core-215k</link>
      <guid>https://dev.to/freecoderzhaoshuai/which-is-faster-to-make-a-web-api-python-or-net-core-215k</guid>
      <description>&lt;p&gt;database is same(sql server)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>IF a develop team's people number is only 2,is it necessary to do unit test before publish?</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Wed, 10 Jun 2020 07:50:20 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/if-a-develop-team-s-people-number-is-only-2-is-it-necessary-to-do-unit-test-before-publish-42kf</link>
      <guid>https://dev.to/freecoderzhaoshuai/if-a-develop-team-s-people-number-is-only-2-is-it-necessary-to-do-unit-test-before-publish-42kf</guid>
      <description>

</description>
      <category>netcore</category>
    </item>
    <item>
      <title>Who can give me some simples that nodejs query redis cache by value propetry</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Wed, 10 Jun 2020 07:43:20 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/who-can-give-me-some-simples-that-nodejs-query-redis-cache-by-value-propetry-3j49</link>
      <guid>https://dev.to/freecoderzhaoshuai/who-can-give-me-some-simples-that-nodejs-query-redis-cache-by-value-propetry-3j49</guid>
      <description>&lt;p&gt;Sorry for my poor english.&lt;br&gt;
I am trying to work out backing up some data from redis cache to sql server.&lt;br&gt;
but I found its hard to query redis data by its values propetry&lt;/p&gt;

</description>
      <category>netcore</category>
    </item>
    <item>
      <title>https://github.com/NLog/NLog.Extensions.Logging/issues/42</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Sat, 06 Jun 2020 13:41:38 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/https-github-com-nlog-nlog-extensions-logging-issues-42-4699</link>
      <guid>https://dev.to/freecoderzhaoshuai/https-github-com-nlog-nlog-extensions-logging-issues-42-4699</guid>
      <description>&lt;p&gt;at the risk of sounding quick and dirty, I do normally initialize NLog twice. Once in at the beginning of Main() to capture startup errors (ie):&lt;/p&gt;

&lt;p&gt;var nlogEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");&lt;br&gt;
LogManager.LoadConfiguration(nlogEnvironment == "" ? "nlog.config" : $"nlog.{nlogEnvironment}.config");&lt;/p&gt;

&lt;p&gt;var logger = LogManager.GetCurrentClassLogger();&lt;br&gt;
and then again using the cleanest method for either Generic Host (HostBuilder)(My preference since netcore seems to be shifting this way in general) or Web Host (WebHostBuilder) both methods are similar, but neither use a Startup or the traditional IAppBuilder, IHostingEnvironment,ConfigureServices pattern.&lt;/p&gt;

&lt;p&gt;My warning here is that ASPNETCORE_ENVIRONMENT is unpredictable. For example, it's not even set on my machine. It can be set manually in the environment, set via command line arg, in an IIS config, or App/Site configs (among other places). Let me specify: It's unpredictable that early. You can specify programmatically which sources you read the setting from and in what order to respect them when you're configuring services, but not before you start to configure the host. See my example below:&lt;/p&gt;

&lt;p&gt;Hence, I wrap it in #if(DEBUG). The idea is that you Do as little as possible in Main() and you should not have to rely on logging before your host is configured. If something goes wrong in your configured services, your logger is already started before even the host starts (remember that everything you do is just configuration, telling the host how it's going to start up. Nothing actually "happens" until you build and then run your host.) (admittedly this only really applies to netcore 2.x)&lt;/p&gt;

&lt;p&gt;Disclaimer: I'm no expert and all of this could just sound like nonsense to you; If so, I apologize. I err on the side of wordy code for clarity rather than low line count. I code like I picture software components behaving in my head. It helps when I'm tasked with containerizing things that were never meant to be containerized.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>how to survive when coder is  35 years old </title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Fri, 05 Jun 2020 03:02:30 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/how-to-survive-when-coder-is-35-years-old-1lg2</link>
      <guid>https://dev.to/freecoderzhaoshuai/how-to-survive-when-coder-is-35-years-old-1lg2</guid>
      <description>&lt;p&gt;in chinese 35 years old means retire&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Scaffold new tables and keep the existed ones?</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Thu, 04 Jun 2020 08:37:44 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/scaffold-new-tables-and-keep-the-existed-ones-44nm</link>
      <guid>https://dev.to/freecoderzhaoshuai/scaffold-new-tables-and-keep-the-existed-ones-44nm</guid>
      <description>&lt;p&gt;I wish there were a built-in way to add entities and update an existing context, but there doesn't seem to be. I overcame this by using the --context option in the package manager console and just gave it a temporary name, e.g. --context TempContext. This worked and generated the new table and the temp context. Then I just copied the public virtual DbSet NewEntityType { get; set; } property and the modelBuilder.Entity(entity =&amp;gt; block from the OnModelCreating method in the temp context to my existing one. After that, I deleted the temp context. It's pretty straightforward.&lt;/p&gt;

</description>
      <category>efcore</category>
    </item>
    <item>
      <title>c# GetEnvironmentVariable without restart pc</title>
      <dc:creator>freecoderzhaoshuai</dc:creator>
      <pubDate>Tue, 02 Jun 2020 06:17:34 +0000</pubDate>
      <link>https://dev.to/freecoderzhaoshuai/c-getenvironmentvariable-without-restart-pc-39pb</link>
      <guid>https://dev.to/freecoderzhaoshuai/c-getenvironmentvariable-without-restart-pc-39pb</guid>
      <description>&lt;p&gt;var value = Environment.GetEnvironmentVariable(key, EnvironmentVariableTarget.User)&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
