Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Innovating

Chandan Gupta Bhagat chandan-g-bhagat

🎯
Innovating
View GitHub Profile
@chandan-g-bhagat
chandan-g-bhagat / sqlclient.cs
Created Aug 2, 2021
CRUD Operation on Person table
View sqlclient.cs
private static string connectionstring = "Data Source=DESKTOP-C25RLDB\\SQLEXPRESS;Initial Catalog=Academia;integrated security=true;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
private static void DataBaseConnection()
{
Console.WriteLine("Press 1 to read from PersonTable");
Console.WriteLine("Press 2 to insert in PersonTable");
Console.WriteLine("Press 3 to edit in PersonTable");
Console.WriteLine("Press 4 to delete from PersonTable");
var choice = Console.ReadLine();
switch (choice)
@chandan-g-bhagat
chandan-g-bhagat / simpletable.sql
Last active Jul 26, 2021
Query to create the student, parent and studentparent table
View simpletable.sql
create table student
(
id int not null primary key identity(1,1),
studentname nvarchar(50) not null
)
create table parent
(
id int not null primary key identity(1,1),
parentname nvarchar(50) not null ,
@chandan-g-bhagat
chandan-g-bhagat / runtime.cs
Created Jul 24, 2021
Execute the C# code in runtime
View runtime.cs
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System;
namespace RuntimeCompile
{
internal class Program
{
private static void Main(string[] args)
{
@chandan-g-bhagat
chandan-g-bhagat / Seed Code.cs
Created Jun 11, 2021
Seed function for student and admin
View Seed Code.cs
protected override void Seed(School.Web.Models.ApplicationDbContext db)
{
var roleStore = new RoleStore<IdentityRole>(db);
var roleManager = new RoleManager<IdentityRole>(roleStore);
if (!(db.Roles.Any(p => p.Name == "Admin")))
{
roleManager.Create(new IdentityRole() { Name = "Admin" });
}
if (!(db.Roles.Any(p => p.Name == "Student")))
@chandan-g-bhagat
chandan-g-bhagat / sql_Complex.txt
Created May 26, 2021
Student Parent Complex query
View sql_Complex.txt
create table Student
(
Id int primary key not null identity(1,1),
Student nvarchar(50) not null,
)
create table Parent
(
Id int primary key not null identity(1,1),
View sql basics.txt
--switches the database
USE <DB-NAME>
Go
--CREATE the database
CREATE DATABASE <DB-NAME>
GO
--CREATE the table
CREATE TABLE <TABLE NAME>
@chandan-g-bhagat
chandan-g-bhagat / cloneAndBuild.sh
Last active May 5, 2021
Clone and Build dotnet core projects
View cloneAndBuild.sh
while [ $# -gt 0 ]; do
if [[ $1 == *"--"* ]]; then
v="${1/--/}"
declare $v="$2"
fi
shift
done
View program.cs
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Broadway.Projects
{
class Program
View gist:5611995ec4dc546422d2827c302c859c
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibraryTest.Computer
{
public class Stack
{
View DockerFile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /src
COPY ["Project1/Project1.csproj", "Project1/"]
RUN dotnet restore "Project1/Project1.csproj"
#COPY . .