Instantly share code, notes, and snippets.

View 2018-02-10-publishingnugetotvsts_003.cmd
nuget.exe push -Source "MyFeedName" -ApiKey VSTS Subfolder\bin\Release\MyProject.nupkg
View 2018-02-10-publishingnugetotvsts_002.cmd
start nuget.exe pack Subfolder\MyProject.csproj -OutputDirectory Subfolder\bin\Release -symbols -IncludeReferencedProjects -Prop Configuration=Release
View 2018-02-10-publishingnugetotvsts_001.xml
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<Exec Command="$(SolutionDir)\NuGet.exe pack $(ProjectPath) -IncludeReferencedProjects -Prop Configuration=Release">
</Exec>
</Target>
View 2016-01-14-custom-properties-in-log4net-logging_003bis.xml
<layout type="log4net.Layout.PatternLayout">
<converter>
<name value="HTTPUser" />
<type value="hbulens.Logging.HttpContextUserPatternConverter" />
</converter>
<conversionPattern value="%level %date - %message - [%property{Category}] - [%HTTPUser] %newline" />
</layout>
View 2015-07-24-how-to-automatically-load-navigation-properties-in-entity-framework_003.cs
public virtual IQueryable<TEntity> FindAll(Expression<Func<TEntity, bool>> where = null)
{
IQueryable<TEntity> query = where == null ? this.Context.Set <TEntity> () : this.Context.Set<TEntity>().Where(where);
var workspace = ((IObjectContextAdapter)this.Context).ObjectContext.MetadataWorkspace;
var itemCollection = (ObjectItemCollection)(workspace.GetItemCollection(DataSpace.OSpace));
var entityType = itemCollection.OfType<EntityType>().FirstOrDefault(e => itemCollection.GetClrType(e) == typeof(TEntity));
if (entityType != null)
{
View 2015-07-24-how-to-automatically-load-navigation-properties-in-entity-framework_001.cs
public class Blog
{
public int BlogId { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Tags { get; set; }
public ICollection<Post> Posts { get; set; }
}
View 2015-05-05-c-and-the-wordpress-api_002.cs
public static string CharacterLimit(this string text, int length)
{
if (text.Length <= length) return text;
int pos = text.IndexOf(" ", length);
if (pos >= 0) return text.Substring(0, pos) + "...";
return text;
}
View 2015-05-26-developing-real-time-applications-with-signalr-and-sqldependency-in-asp-net-mvc-and-c_004.cs
public JsonResult GetMessages()
{
using(FleetContext ctx = new FleetContext())
{
IEnumerable<string> messages = ctx.Insurers.AsQueryable().Cast<Insurer>().Select(x => x.Name).ToList();
var dataOutput = Json(messages, JsonRequestBehavior.AllowGet);
return dataOutput;
}
}