Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 329a5df

Browse files
committed
Update README with new info from release notes
1 parent e58d160 commit 329a5df

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

README.md

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ OrmLite was designed with a focus on the core objectives:
1616
* Expressive power and flexibility - with access to IDbCommand and raw SQL
1717
* Cross platform - supports multiple dbs (currently: Sql Server, Sqlite, MySql, PostgreSQL, Firebird) running on both .NET and Mono platforms.
1818

19-
In OrmLite: **1 Class = 1 Table**. There should be no surprising or hidden behaviour.
20-
Any non-scalar properties (i.e. complex types) are by default text blobbed in a schema-less text field using any of the [avilable pluggable text serializers](#pluggable-complex-type-serializers). Support for [POCO-friendly references](#reference-support-poco-style) is also available to provide a convenient API to persist related models. Effectively this allows you to create a table from any POCO type and it should persist as expected in a DB Table with columns for each of the classes 1st level public properties.
19+
In OrmLite: **1 Class = 1 Table**. There should be no surprising or hidden behaviour, the Typed API
20+
that produces the Query doesn't impact how results get intuitvely mapped to the returned POCO's which
21+
could be different to the POCO used to create the query, e.g. containing only a subset of the fields
22+
you want populated.
23+
24+
Any non-scalar properties (i.e. complex types) are text blobbed by default in a schema-less text field
25+
using any of the [avilable pluggable text serializers](#pluggable-complex-type-serializers).
26+
Support for [POCO-friendly references](#reference-support-poco-style) is also available to provide
27+
a convenient API to persist related models. Effectively this allows you to create a table from any
28+
POCO type and it should persist as expected in a DB Table with columns for each of the classes 1st
29+
level public properties.
2130

2231
# Download
2332

@@ -48,6 +57,66 @@ Contributors need to approve the [Contributor License Agreement](https://docs.go
4857

4958
***
5059

60+
## Usage
61+
62+
First Install the NuGet package of the RDBMS you want to use, e.g:
63+
64+
PM> Install-Package ServiceStack.OrmLite.SqlServer
65+
66+
Each RDBMS includes a specialized dialect provider that encapsulated the differences in each RDBMS
67+
to support OrmLite features. The available Dialect Providers for each RDBMS is listed below:
68+
69+
SqlServerDialect.Provider // Any SQL Server
70+
SqliteDialect.Provider // Sqlite
71+
SqlServer2012Dialect.Provider // SQL Server 2012+
72+
PostgreSqlDialect.Provider // PostgreSQL
73+
MySqlDialect.Provider // MySql
74+
OracleDialect.Provider // Oracle
75+
VistaDbDialect.Provider // Vista DB
76+
FirebirdDialect.Provider // Firebird
77+
78+
To configure OrmLite you need the DB Connection string along the Dialect Provider of the RDBMS you're
79+
connecting to, e.g:
80+
81+
```csharp
82+
var dbFactory = new OrmLiteConnectionFactory(
83+
connectionString,
84+
SqlServerDialect.Provider);
85+
```
86+
87+
If you're using an IOC you can register `OrmLiteConnectionFactory` as a **singleton**, e.g:
88+
89+
```csharp
90+
container.Register<IDbConnectionFactory>(c =>
91+
OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider)); //E.g of In Memory Sqlite DB
92+
```
93+
94+
Use the `dbFactory` to open an ADO.NET DB Connection to your database.
95+
If connecting to an empty database you can use OrmLite's Create Table API's to create any tables
96+
you need based on the Schema definition of your POCO and populate it with any initial seed data
97+
you need, e.g:
98+
99+
```csharp
100+
using (var db = dbFactory.Open())
101+
{
102+
if (db.CreateTableIfNotExists<Poco>())
103+
{
104+
db.Insert(new Poco { Id = 1, Name = "Seed Data"});
105+
}
106+
107+
var result = db.SingleById<Poco>(1);
108+
result.PrintDump(); //= {Id: 1, Name:Seed Data}
109+
}
110+
```
111+
112+
## [Type Converters](https://github.com/ServiceStack/ServiceStack.OrmLite/wiki/OrmLite-Type-Converters)
113+
114+
You can customize, enhance or replace how OrmLite handles different .NET Types with
115+
[OrmLite Type Converters](https://github.com/ServiceStack/ServiceStack.OrmLite/wiki/OrmLite-Type-Converters).
116+
117+
See the [[SQL Server Types]] wiki for how to enable support for SQL Server-specific
118+
`SqlGeography`, `SqlGeometry` and `SqlHierarchyId` Types.
119+
51120
## Dynamic Result Sets
52121

53122
There's new support for returning unstructured resultsets letting you Select `List<object>` instead of having results mapped to a concrete Poco class, e.g:
@@ -93,6 +162,17 @@ or use `object` to fetch an unknown **Scalar** value:
93162
object result = db.Scalar<object>(db.From<Poco>().Select(x => x.Id));
94163
```
95164

165+
## Nested Typed Sub SqlExpressions
166+
167+
The `Sql.In()` API supports nesting and combining of multiple Typed SQL Expressions together
168+
in a single SQL Query, e.g:
169+
170+
```csharp
171+
var usaCustomerIds = db.From<Customer>(c => c.Country == "USA").Select(c => c.Id);
172+
var usaCustomerOrders = db.Select(db.From<Order>()
173+
.Where(q => Sql.In(q.CustomerId, usaCustomerIds)));
174+
```
175+
96176
# Async API Overview
97177

98178
A quick overview of Async API's can be seen in the class diagram below:

0 commit comments

Comments
 (0)