This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sure, here is the code for a Windows Service with the Microsoft.Extensions.Hosting.BackgroundService: | |
*/ | |
using Microsoft.Extensions.Hosting; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.EntityFrameworkCore; | |
namespace MyService | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Q: explain the meaning of default in | |
private DispatcherTimer timer = default!; | |
/* | |
Bard:: | |
Sure. The default keyword in the code private DispatcherTimer timer = default!; means that the timer variable will be initialized with the default value for a DispatcherTimer object. In this case, the default value is a DispatcherTimer object that is not running and has a Interval of 0 milliseconds. | |
The default! syntax is a new feature in C# 10 that allows you to explicitly specify that the default value should be used. This is useful for preventing the compiler from inferring the wrong type for the variable. In this case, the compiler could have inferred that the timer variable is a Nullable<DispatcherTimer> object, but the default! syntax prevents this from happening. | |
Here is a breakdown of the code: | |
• private - This keyword specifies that the timer variable is private. This means that it can only be accessed by other members of the class in which it is declared. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Show sample code for MyDbInitializer() | |
=> | |
Sure, here is a sample code for MyDbInitializer(): | |
*/ | |
public class MyDbInitializer : DbInitializer | |
{ | |
public override void Seed(DbContext context) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* how to use the CHECK constraint to enforce the data type and length of the AgentCode column in the Agent table: */ | |
CREATE TABLE [dbo].[Agent]( | |
[AgentID] [int] IDENTITY(1,1) NOT NULL, | |
[AgentCode] [char](8) NULL, | |
[Invalid] [bit] NULL, | |
[ExtSysAgentGuid] [uniqueidentifier] NULL, | |
[BusinessName] [nvarchar](200) NULL, | |
... | |
CONSTRAINT [CHECK_AgentCode] CHECK ([AgentCode] IS NULL OR [AgentCode] LIKE '____-____') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Apple", | |
"color": "Red", | |
"taste": "Sweet" | |
}, | |
{ | |
"name": "Banana", | |
"color": "Yellow", | |
"taste": "Sweet" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The command to create and checkout a branch with a single step is: | |
``` | |
git checkout -b <branch_name> | |
``` | |
Here's a breakdown of the command: | |
* `git checkout`: This is the command used for switching branches. | |
* `-b`: This flag tells `git checkout` to create a new branch if it doesn't already exist, **and** switch to the newly created or existing branch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dialog = new FolderBrowserDialog(); | |
dialog.ShowDialog(); | |
folderpathTB.Text = dialog.SelectedPath; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 Change the DB to single-user mode; | |
e.g. in SQL Configuration Manager, SQL Server services / <Your Server> / Properties / Startup Parameters | |
-f (Add, Apply) | |
RESTART (or stop, start) | |
#2 | |
C:\Users\Administrator>SQLCMD -H $localhost | |
1> CREATE LOGIN newSA WITH PASSWORD = 'Pass@123' | |
2> go | |
1> ALTER SERVER ROLE sysadmin ADD MEMBER newSA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List ALL branches | |
>git branch | |
LIST branches by wildcard | |
>git branch --list "122160*" | |
====================== | |
CLONE A SINGLE BRANCH | |
====================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @result int | |
SET @result = (NEXT VALUE FOR dbo.auto_seq) | |
select @result |