Skip to content

Instantly share code, notes, and snippets.

View jholt456's full-sized avatar

Joshua Holt jholt456

  • WellDatabase
  • Houston, TX
View GitHub Profile
@jholt456
jholt456 / cleanup.sh
Last active January 21, 2021 20:51 — forked from superseb/cleanup.sh
Cleanup host added as custom to Rancher 2.0
#!/bin/bash
user=$EUID
if [ "${user}" != "0" ]; then
echo
echo "$0 must be run as root - you are running as $EUID"
echo
exit 1
fi
echo
echo "About to destroy Rancher 2.x install"
@jholt456
jholt456 / SqlDbType2DbType.cs
Created January 28, 2019 03:57 — forked from tecmaverick/SqlDbType2DbType.cs
Convert .Net Type to SqlDbType or DbType and vise versa
//Convert .Net Type to SqlDbType or DbType and vise versa
//This class can be useful when you make conversion between types .The class supports conversion between .Net Type , SqlDbType and DbType .
using System;
using System.Collections;
using System.Data;
namespace Devintelligence.Common.Data
{
/// <summary>
public class CategoryController : Controller
{
private TodoDataContext db = new TodoDataContext();
//
// GET: /Category/
public ViewResult Index()
{
return View(db.Categories.ToList());
@jholt456
jholt456 / FluentMappingSource.cs
Created April 2, 2012 20:41
OpenAccess ORM Xml To Object Converter
public class MyMetadataSource : FluentMetadataSource
{
protected override Telerik.OpenAccess.Metadata.MetadataContainer CreateModel()
{
var container = base.CreateModel();
container.NameGenerator.UseDefaultMapping = true;
return container;
}
protected override IList<MappingConfiguration> PrepareMapping()
@jholt456
jholt456 / JSONPpartial.cs
Created February 6, 2012 23:12
KendoUI Grid With OData Service
[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[JSONPSupportBehavior]
public partial class NorthwindService : OpenAccessDataService<KendoUIOAOData.EntitiesModel>
{
//Rest of code omitted
@jholt456
jholt456 / OA DynamicData
Created November 22, 2011 23:44
Configuring OpenAccess ORM for dynamic data
DefaultModel.RegisterContext(new OpenAccessDataModelProvider(new EntitiesModel() /*the name of your OpenAccess Context*/,
() => new EntitiesModel() /*the name of your OpenAccess Context*/),
new ContextConfiguration { ScaffoldAllTables = false });
@jholt456
jholt456 / Class Skeleton
Created October 4, 2011 22:20
Enum2String Type Converter
public class EnumToStringConverter<TEnum> : Telerik.OpenAccess.Data.AdoTypeConverter where TEnum : struct
{
/// <summary>
/// Reads data from the data reader into the type
/// </summary>
/// <param name="holder">A place where the read data can be stored unboxed</param>
/// <returns>Value that was read or <c>null</c> when boxing is turned off</returns>
public override object Read(ref DataHolder holder)
{
return null;
@jholt456
jholt456 / DataReaderExtensions
Created September 30, 2011 21:54
Telerik OpenAccess Context Extensions
public static class DataReaderExtensions
{
public static List<dynamic> ToDynamicList(this IDataReader reader)
{
var result = new List<dynamic>();
while (reader.Read())
{
ExpandoObject item = new ExpandoObject();
var itemDictionary = item as IDictionary<string, object>;
for (int i = 0; i < reader.FieldCount; i++)
@jholt456
jholt456 / Class
Created September 8, 2011 21:29
Custom OpenAccess TypeConverter Class
public class Varchar2IntConverter : Telerik.OpenAccess.Data.AdoTypeConverter
{
//create flag to mark whether the CLR type is nullable or not
private bool nullable;
}
@jholt456
jholt456 / DefaultType.cs
Created September 8, 2011 21:21
Custom OpenAccess TypeConverter DefaultType Property
public override Type DefaultType
{
get { return typeof(int); }
}