Skip to content

Instantly share code, notes, and snippets.

@bhameyie
bhameyie / gist:5666703
Created May 28, 2013 22:40
simple.data example 1
public class Story
{
public long Id { get; set; }
public string Description { get; set; }
public string Title { get; set; }
public StoryStatus Status { get; set; }
public long CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime LastEditedOn { get; set; }
public long ProjectId { get; set; }
@bhameyie
bhameyie / gist:5666712
Last active December 17, 2015 20:19
Simple.data sample inserts & delete
//Inserting a story
var database = Database.OpenConnection(m_connectionString);
var result = database.Stories.Insert(entity); //This doesn’t save the Project or Tasks associated with the story. The result being return is the saved object with an updated Id.
//updating
var inserted = database.Stories.Update(entity);
//sample update all
database.Stories.UpdateAll(Title: "Glorious");
database.Stories.UpdateAll(database.Stories.Estimate > 10, Title: “Break me down into multiple smaller stories");
@bhameyie
bhameyie / gist:5666748
Created May 28, 2013 22:48
Nuget with albacore
def readVersion(filepath="AssemblyInfo.cs")
File.open(filepath).each_line{ |line|
if line.start_with?("[assembly: AssemblyVersion(\"")
return line.gsub("[assembly: AssemblyVersion(\"", "").gsub("\")]","").gsub(/\s+/, "")
end
}
end
@bhameyie
bhameyie / gist:5666780
Created May 28, 2013 22:58
Datactontract serializer with json
public class UploadServceClient
{
RestClient RestClient;
public UploadServceClient()
{
RestClient = new RestClient("http://localhost/MyService");
}
@bhameyie
bhameyie / gist:5666809
Last active December 17, 2015 20:19
Dynamic database wrapper
//a class wrapping the actual dynamic object
public class Database
{
public static dynamic Open()
{
return new DynamicDatatbase();
}
public static dynamic Open(string connectionString, string providerName)
{
@bhameyie
bhameyie / gist:5666822
Created May 28, 2013 23:05
dynamic query builder
public class DynamicQueryBuilder : DynamicObject
{
private readonly string m_tableName;
private string internalQuery;
public DynamicQueryBuilder(string tableName)
{
m_tableName = tableName;
}
@bhameyie
bhameyie / gist:5666836
Created May 28, 2013 23:07
dynamic table
public class DynamicTable : DynamicObject
{
private readonly DataTable m_dataTable;
public DynamicTable(DataTable dataTable)
{
m_dataTable = dataTable;
}
public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
@bhameyie
bhameyie / gist:5666861
Created May 28, 2013 23:12
query data with dynamic
class Person
{
public int Id { get; set; }
public int Age { get; set; }
public string Name { get; set; }
public Person()
{
}
@bhameyie
bhameyie / gist:5666884
Created May 28, 2013 23:17
simple tabhost
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
@bhameyie
bhameyie / gist:5666887
Created May 28, 2013 23:18
Tabhost activity
[Activity(Label = "Detail")]
public class DetailActivity : Activity
{
private FakeFashionImageThumbnail m_fakeFashionImageDetail;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Detail);
var tabHost = FindViewById<TabHost>(Resource.Id.detailTabhost);