Skip to content

Instantly share code, notes, and snippets.

@danielwertheim
Created July 19, 2012 22:05
Show Gist options
  • Select an option

  • Save danielwertheim/3147197 to your computer and use it in GitHub Desktop.

Select an option

Save danielwertheim/3147197 to your computer and use it in GitHub Desktop.
SisoDb - Inheritance
class Program
{
static void Main(string[] args)
{
var db = "data source=.;initial catalog=fff;integrated security=true;".CreateSql2012Db();
db.CreateIfNotExists();
var p = new Foo2 { Name = "Adam", Points = 1 };
db.UseOnceTo().Insert<Foo>(p);
}
}
public class Foo
{
public Guid StructureId { get; set; }
public string Name { get; set; }
}
public class Foo2 : Foo
{
public int Points { get; set; }
}
use fff;
//We see on the naming that Foo has been used as contract, otherwise it should have been Foo2
select * from dbo.FooIntegers;
select * from dbo.FooStrings;
select Json from dbo.FooStructure;
RowId StructureId MemberPath
-------------------- ------------------------------------ ------------------
(0 row(s) affected)
RowId StructureId MemberPath
-------------------- ------------------------------------ ------------------
1 689AB380-EDD1-E111-9AB3-5404A6F3A57D Name
(1 row(s) affected)
Json
----------------------------------------------------------------------------
{"Points":1,"StructureId":"689ab380edd1e1119ab35404a6f3a57d","Name":"Adam"}
(1 row(s) affected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment