Skip to content

Instantly share code, notes, and snippets.

CREATE PROCEDURE [dbo].[UserAccount_Create]
(
@Name varchar(10)
, @FullName varchar(100)
, @LoginTitle varchar(100) = null
, @LoginMessage varchar(2000) = null
, @WelcomeMessage varchar(8000) = null
, @Domain varchar(100) = null
, @RegionId int = null
, @ExternalRef varchar(50) = null
public static TResult With<TInput, TResult>(this TInput o,
Func<TInput, TResult> evaluator)
where TResult : class
where TInput : class
{
if (o == null) return null;
return evaluator(o);
}
public static TResult Return<TInput, TResult>(this TInput o,
SELECT * FROM information_schema.tables
select * from information_schema.columns where table_name = [table name]
@model EditUserModel
@using (Html.BeginForm())
{
<div>
@Html.HiddenFor(m => m.Id)
@Html.TextBoxFor(m => m.FirstName)
@Html.TextBoxFor(m => m.LastName)
@Html.DropDownListFor(m => m.CountryId, Model.Countries.Select(c => new SelectListItem { Value = c.Id, Text = c.Name })
@model EditUserModel
@using (Html.BeginForm())
{
<div>
@Html.HiddenFor(m => m.Id)
@Html.TextBoxFor(m => m.FirstName)
@Html.TextBoxFor(m => m.LastName)
@Html.DropDownListFor(m => m.CountryId, Model.Countries)
@model UserViewModel
@using (Html.BeginForm())
{
<div>
@Html.HiddenFor(m => m.Id)
@Html.TextBoxFor(m => m.FirstName)
@Html.TextBoxFor(m => m.LastName)
@Html.DropDownListFor(m => m.CountryId, Model.Countries)
@amogram
amogram / stringjoin
Created April 15, 2014 15:08
Using string.Join to flatten dictionary of strings, ordered by value.
string res = "";
var displayOrder = new Dictionary<string, int>(){{"string 2",2},{"string 1",1},{"string 3",3}};
res= string.Join(" - ",displayOrder.OrderBy(x => x.Value).Select(x=>x.Key));
// dump to LINQPad
res.Dump();
@amogram
amogram / stringAggregate
Created April 15, 2014 15:01
DIsplay items in dictionary in order.
string res = "";
var displayOrder = new Dictionary<string, int>(){{"string two",2},{"string 1",1},{"string 3",3}};
res = "Person ID" + displayOrder.OrderBy(x => x.Value).Aggregate(res, (current, x) => current + " - " + x.Key);
// for demo in LINQPad
res.Dump();
@amogram
amogram / chocolatey-env-setup.ps1
Last active August 17, 2021 14:19
A Chocolatey script for PowerShell I use to set up my Windows development environment. I use this when setting up my own Dev VMs. Use at your own risk.See http://bit.ly/1a301JK and http://chocolatey.org/ for more information.
# Simple environment setup script
# Install Applications
choco install fiddler4
choco install notepadplusplus
choco install visualstudiocode
choco install greenshot
choco install GoogleChrome
choco install putty
choco install ccleaner
@amogram
amogram / gist:5389180
Created April 15, 2013 16:02
Quick and dirty Timestamp extension method.
public static class DateTimeExtensions
{
public static String GetTimestamp(this DateTime value)
{
return value.ToString("yyyyMMddHHmmssffff");
}
}