Created
May 9, 2018 13:57
-
-
Save markholdt/991ae7b338267897bd9400f295c1835b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using ServiceStack.OrmLite; | |
using ServiceStack.OrmLite.Sqlite; | |
using ServiceStack.DataAnnotations; | |
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider); | |
var db = dbFactory.Open(); // Open ADO.NET DB Connection | |
public class Price | |
{ | |
public Guid Id { get; set; } // 'Id' is PrimaryKey by convention | |
public string PriceDate {get;set;} | |
} | |
// Delete and Recreate above schema | |
if (!db.TableExists<Price>()) | |
db.CreateTable<Price>(); // Delete ForeignKey data if exists | |
var savedPrice = new Price | |
{ | |
Id = Guid.NewGuid(), | |
PriceDate = "20180101" | |
}; | |
db.Insert(savedPrice); | |
var savedPrice2 = new Price | |
{ | |
Id = Guid.NewGuid(), | |
PriceDate = "20180102" | |
}; | |
db.Insert(savedPrice2); | |
// Load Player Record and its Referenced Data | |
var dbPlayer = db.Select<Price>(ar => ar.PriceDate <= "20180101"); | |
dbPlayer.PrintDump(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment