Skip to content

Instantly share code, notes, and snippets.

@mythz mythz/main.cs
Created Jun 4, 2018

Embed
What would you like to do?
SelectMulti example
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 Customer
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Address
{
public int Id { get; set; }
public int CustomerId { get; set; }
}
db.CreateTable<Customer>();
db.CreateTable<Address>();
db.Insert(new Customer { Id = 1, Name = "C" });
db.Insert(new Address { Id = 1, CustomerId = 1 });
var q = db.From<Customer>()
.Join<Customer,Address>();
var results = db.SelectMulti<Customer, Address>(q);
results.PrintDump();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.Common" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.OrmLite" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.OrmLite.Sqlite" version="5.0.2" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.