Skip to content

Instantly share code, notes, and snippets.

View ewhitmore's full-sized avatar

Eric Whitmore ewhitmore

  • Whitmore Consulting LLC
View GitHub Profile
@ewhitmore
ewhitmore / SQL Tables to C# Objects
Created May 26, 2016 15:53
SQL Tables to C# Objects
declare @TableName sysname = 'Registration'
declare @Result varchar(max) = 'public class ' + @TableName + '
{'
select @Result = @Result + '
public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }
'
from
(
select
@ewhitmore
ewhitmore / EntityBaseMap.cs
Created April 19, 2016 14:11
NHibernate Base Map
public abstract class EntityBaseMap<T> : ClassMap<T> where T : EntityBase<T>
{
protected EntityBaseMap()
{
DynamicUpdate(); // Hibernate will update the modified columns only.
Id(x => x.Id).Column("Id"); // Numberic Id
Map(x => x.IsDeleted);
Map(x => x.CreatedAt);
OptimisticLock.Version();
@ewhitmore
ewhitmore / CustomDialect.cs
Created April 19, 2016 14:09
CustomDialect for SQLITE which support DATETIME2
public class CustomDialect : SQLiteDialect
{
protected override void RegisterColumnTypes()
{
base.RegisterColumnTypes();
RegisterColumnType(DbType.DateTime2, "DATETIME2");
}
protected override void RegisterFunctions()
{
@ewhitmore
ewhitmore / gist:8671930
Created January 28, 2014 17:15
C# WebAPI - Angularjs $resource decimal hack
[HttpPut]
[Authorize(Roles = "VendorAdmin")]
[Route("{id:int}/SetPrice/{price:decimal}")]
public IHttpActionResult SetPrice(int id, decimal price)
{
//...
try
{
PricingAgreementItemService.SetPrice(id, price);
@ewhitmore
ewhitmore / gist:8671859
Last active January 4, 2016 20:09
C# WebAPI - Angularjs $resource decimal hack
app.factory('PricingAgreementItemSvc', function ($resource) {
return $resource('/api/pricingAgreementItem/:id/:action/:value\\/', { id: '@id' },
{
// ...
setPrice: {
method: 'PUT',
params: {
id: '@id',
action: 'SetPrice',
value: '@value'
@ewhitmore
ewhitmore / gist:7519178
Created November 17, 2013 22:35
Visual Studio 2013 Jasmine/AngularJS Spec
/// <reference path="../../Scripts/jasmine/jasmine.js" />
/// <reference path="../../Scripts/angular.js" />
/// <reference path="../../Scripts/angular-mocks.js" />
/// <reference path="../../Scripts/angular-resource.js" />
/// <reference path="../../Scripts/angular-route.js" />
/// <reference path="../../Scripts/ui-bootstrap-tpls-0.6.0.js" />
/// <reference path="../app.js" />
/// <reference path="../DataEntry/DataEntryCtrl.js" />