Skip to content

Instantly share code, notes, and snippets.

@carlhoerberg
carlhoerberg / QuerableExtensions.cs
Created August 25, 2010 15:17
Dynamic LINQ OrderBy extension method
public static class QuerableExtensions
{
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property, bool asc)
{
return ApplyOrder<T>(source, property, asc ? "OrderBy" : "OrderByDescending");
}
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property)
{
return ApplyOrder<T>(source, property, "OrderBy");
}
@carlhoerberg
carlhoerberg / SyncDB.cmd
Created May 27, 2010 11:38
Sync two MsSql databases
@echo off
setlocal
set path="%programfiles%\IIS\Microsoft Web Deploy";%PATH%
msdeploy -verb:sync -source:dbFullSql="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true",computerName=yourcomputer.com ^
-dest:dbFullSql="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true",dropDestinationDatabase=true
endlocal
@carlhoerberg
carlhoerberg / MigrateAndGenerateContext.cmd
Created May 26, 2010 09:47
Work with Linq to Sql and Migrator
@echo off
setlocal
set path="%CommonProgramFiles(x86)%\microsoft shared\TextTemplating\10.0";"%ProgramFiles(x86)%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools";%path%
set connStr="Data Source=.\SQLEXPRESS;Initial Catalog=MyDB;Integrated Security=true"
REM Download MigratorDotNet from http://code.google.com/p/migratordotnet/
echo Applying migrations
..\Libs\Migrator\Migrator.Console SqlServer %connStr% "..\MyProject.Migrations\Bin\Debug\MyProject.Migrations.dll" -trace
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" /> <!-- Require SSL must be OFF in the site settings -->
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<System.Web.UI.DataVisualization.Charting.Chart>" %>
<%
Model.Page = this.Page;
var writer = new HtmlTextWriter(Page.Response.Output);
Model.RenderControl(writer);
%>