You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 24, 2022. It is now read-only.
Extension methods hang off the implementation agnostic ADO.NET `IDbConnection`.
326
+
327
+
`CreateTable<T>` and `DropTable<T>` create and drop tables based on a classes type definition (only public properties used).
328
+
329
+
By default Selection methods use parameterized SQL whilst any selection methods ending with **Fmt** allow you to construct Sql using C# `string.Format()` syntax.
330
+
331
+
If your SQL doesn't start with a **SELECT** statement, it is assumed a WHERE clause is being provided, e.g:
332
+
333
+
```csharp
334
+
vartracks=db.SelectFmt<Track>("Artist = {0} AND Album = {1}", "Nirvana", "Heart Shaped Box");
335
+
```
336
+
337
+
The same results could also be fetched with:
338
+
339
+
```csharp
340
+
vartracks=db.SelectFmt<Track>("select * from track WHERE Artist={0} AND Album={1}", "Nirvana", "Heart Shaped Box");
- All **Insert**, **Update**, and **Delete** methods take multiple params, while `Insert`, `UpdateAll` and `DeleteAll` take IEnumerables.
408
+
-`Save` and `SaveAll` will Insert if no record with **Id** exists, otherwise it Updates.
409
+
- Methods containing the word **Each** return an IEnumerable<T> and are lazily loaded (i.e. non-buffered).
410
+
411
+
317
412
# Features
318
413
319
414
OrmLite's goal is to provide a convenient, DRY, RDBMS-agnostic typed wrapper that retains a high affinity with SQL, exposing an intuitive API that generates predictable SQL and straight-forward mapping to clean, disconnected (DTO-friendly) POCO's. This approach makes easier to reason-about your data access as it's obvious what SQL is getting executed at what time, mitigating unexpected behavior, implicit N+1 queries and leaky data access prevalent in Heavy ORMs.
@@ -418,13 +513,13 @@ The mapping also includes a fallback for referencing fully-qualified names in th
418
513
Seeing how the SqlExpression is constructed, joined and mapped, we can take a look at a more advanced example to showcase more of the new API's available:
419
514
420
515
```csharp
421
-
List<FullCustomerInfo>rows=db.Select<FullCustomerInfo>( // Map results to FullCustomerInfo POCO
**Select** statements take in parameterized SQL using properties from the supplied anonymous type (ifany)
1277
-
1278
-
```csharp
1279
-
var track3 = db.Select<Track>("select * fromTrackWhereAlbumName=@albumandTrackNo=@trackNo",
1280
-
new { album="Throwing Copper", trackNo=3 })
1281
-
```
1282
-
1283
-
SingleById(s), SelectById(s), etc provide strong-typed convenience methods to fetch by a Table's **Id** primary key field.
1284
-
1285
-
```csharp
1286
-
var track = db.SingleById<Track>(1);
1287
-
vartracks=db.SelectByIds<Track>(new[]{ 1,2,3 });
1288
-
```
1289
-
1290
1285
### Ignoring DTO Properties
1291
1286
1292
1287
You may use the `[Ignore]` attribute to denote DTO properties that are not fields in the table. This will force the SQL generation to ignore that property.
0 commit comments