Skip to content

Instantly share code, notes, and snippets.

View sannlynnhtun-coding's full-sized avatar
🔥
We live. We code. We yoke.

Sann Lynn Htun sannlynnhtun-coding

🔥
We live. We code. We yoke.
View GitHub Profile

ATM Console Application

1. Application Requirements

  • User Management (UserID, Password, Balance).
  • Login System with 5 attempts.
  • Console alerts like "Login Success".
  • A main menu with 5 options:
    1. Withdraw
    2. Deposit
    3. Check Balance
@sannlynnhtun-coding
sannlynnhtun-coding / blazor-web-assembly-command.md
Created August 13, 2024 04:09
Blazor Web Assembly Command
dotnet publish -c Release -r browser-wasm --self-contained true
public static void DetachAllEntries(this DbContext context)
{
foreach (var entry in context.ChangeTracker.Entries().ToList())
{
context.Entry(entry.Entity).State = EntityState.Detached;
}
}
git shortlog --summary --numbered --all --no-merges
@sannlynnhtun-coding
sannlynnhtun-coding / json-extension.md
Created May 25, 2024 09:41
Newtonsoft Json Extension
public static class DevCode
{
  public static string? ToJson<T>(this T? obj, bool format = false)
    {
        if (obj == null) return string.Empty;
        string? result;
        if (obj is string)
 {
@sannlynnhtun-coding
sannlynnhtun-coding / efcore-global-setting-for-asnotracking.md
Created May 24, 2024 18:27
EFCore Global Setting for AsNoTracking()
builder.Services.AddDbContext<DatabaseContext>(options =>
{
    options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
    options.UseSqlServer(builder.Configuration.GetConnectionString("DbConnection"));
});
@sannlynnhtun-coding
sannlynnhtun-coding / docker-db-installation.md
Last active May 12, 2025 17:02
Docker Database Installation

Microsoft SQL Server

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=sasa@123" -p 1433:1433 --name mssql2022 --hostname mssql2022 -d mcr.microsoft.com/mssql/server:2022-latest

MySQL

docker run --name=mysql-container -e MYSQL_ROOT_PASSWORD=acesa123 -d -p 3306:3306 mysql:latest
@sannlynnhtun-coding
sannlynnhtun-coding / efcore-database-first.md
Last active September 7, 2024 14:15
EFCore Database First
dotnet ef dbcontext scaffold "Server=.;Database=DbName;User Id=userId;Password=password;TrustServerCertificate=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models -c AppDbContext -t Tbl_Name -f
@sannlynnhtun-coding
sannlynnhtun-coding / mssql-db-query.sql
Created May 24, 2024 03:59
Microsoft SQL Server Backup Query
DECLARE @command nvarchar(max)
SET @command = ''
Declare @FileName varchar(500) = 'D:\Backup\LocalDbBackup\' + '@name' +'.bak'''
SELECT @command = @command + 'BACKUP DATABASE ['+name+'] TO DISK = ''' + REPLACE(@FileName, '@name', name) + ';'
FROM sys.databases
where [name] not in ( 'master', 'model', 'msdb', 'tempdb');
SELECT @command
EXECUTE sp_executesql @command