Skip to content

Instantly share code, notes, and snippets.

View JohnMGant's full-sized avatar

Michael Gant JohnMGant

View GitHub Profile
@JohnMGant
JohnMGant / ormexamples.sql
Last active August 1, 2019 20:12
SQL for ORM Examples
select Id, FirstName + ' ' + LastName as Name, coalesce(FavoriteColor, 'Green') as FavoriteColor
from Employees
where LastName like '[whatever you passed in]%'
order by LastName, FirstName
@JohnMGant
JohnMGant / ormexamples.cs
Created August 1, 2019 14:04
ORM examples
internal IEnumerable<Employee> GetEmployees1(string lastName) {
var query =
from emp in context.Employee
where emp.LastName.StartsWith(lastName)
orderby emp.LastName, emp.FirstName
select new Employee {
Id = emp.Id,
Name = emp.FirstName + ' ' + emp.LastName,
FavoriteColor = emp.FavoriteColor ?? "Green"
};
@JohnMGant
JohnMGant / Spaghetti.asp
Last active August 1, 2019 13:22
Example of classic ASP spaghetti code
<html>
<body>
<table>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft SQL Server"
conn.Open "Server=SQLPROD;Database=HR;UserID=SuperDuperAdmin;Password=ABC123!!!"
set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT ID, Name, FavoriteColor " &
"FROM Employees " &