Skip to content

Instantly share code, notes, and snippets.

@wullemsb
wullemsb / DisableCache.cs
Created April 13, 2013 08:43
Disable caching on an ASP.NET MVC action method
public class SomeController:Controller
{
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
public ActionResult NoCache()
{
return View();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Type;
using NHibernate.SqlTypes;
namespace NHibernate
{
/// <summary>
@wullemsb
wullemsb / Unchecked.cs
Created April 20, 2013 12:25
An example of the unchecked keyword in C#
int i = int.MaxValue -50;
unchecked {
i+= 100; //Will just work
}
@wullemsb
wullemsb / checked.cs
Last active December 16, 2015 11:18
An example of the checked keyword in C#
int i = int.MaxValue -50;
checked {
i+= 100; // OverflowException: "Arithmetic operation resulted in an overflow."
}
@wullemsb
wullemsb / ConvertToClaimsUsers.ps1
Created April 26, 2013 15:25
Convert users from a web application to claims identities
$wa = get-SPWebApplication "http://tfssharepoint"
Convert-SPWebApplication -Identity $wa -To Claims –RetainPermissions -Verbose
$wa.MigrateUsers($true)
@wullemsb
wullemsb / MountSharepointContentDB.ps1
Created April 26, 2013 15:57
Mount Sharepoint content database
Mount-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename
@wullemsb
wullemsb / CreateSPWeb.ps1
Created April 26, 2013 16:17
Create sharepoint subsite
$url = "http://tfssharepoint/sites/defaultcollection/mynewsite"
$projectname = "mynewsite"
New-SPWeb -url $url -Name $projectname -Template "Microsoft.TeamFoundation.Sharepoint.Dashboards#0"
@wullemsb
wullemsb / RemoveSPSite.ps1
Created April 26, 2013 16:19
Remove sharepoint subsite
$url= "http://tfssharepoint/sites/defaultcollection/sitetoremove"
Remove-SPSite $url -confirm:$false
function createDocumentLibrary ($webUrl, $libraryName)
{
# varable description
$web = Get-SPWeb $webUrl
$libraryDescription = ""
$libraryTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary;
# Adding Library
try
@wullemsb
wullemsb / EFExplicitLoading.cs
Created May 9, 2013 08:10
Entity Framework Explicit Loading sample
using (var context = new SchoolEntities())
{
course = context.Course.Find(4041);
// Load the students for a given course
context.Entry(course)
.Collection(c => c.Students)
.Load();
}