Skip to content

Commit 2d87edb

Browse files
committed
Add README
1 parent d0cfe65 commit 2d87edb

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
11
# SQLiteSharp
2-
A fork of SQLite-net.
2+
3+
SQLiteSharp is a powerful library to help you access a SQLite database in C#.
4+
5+
## Features
6+
7+
- Create tables from your .NET objects
8+
- Manage your database with SQL commands and No-SQL functions
9+
- Use synchronous and asynchronous APIs
10+
- Encrypt your database with a password or key
11+
12+
## Background
13+
14+
This project is based on [SQLite-net](https://github.com/praeclarum/sqlite-net) by Krueger Systems Inc.
15+
16+
The purpose of SQLiteSharp is to provide improvements to the original library, which is outdated in many ways.
17+
18+
## Example
19+
20+
```cs
21+
public class ShopItem {
22+
[PrimaryKey, AutoIncrement]
23+
public long Id { get; set; }
24+
25+
[NotNull]
26+
public string? ItemName { get; set; }
27+
28+
public long Count { get; set; }
29+
30+
[Ignore]
31+
public int SomethingToIgnore { get; set; }
32+
}
33+
```
34+
35+
```cs
36+
// Open a database connection
37+
using SQLiteConnection Connection = new("database.db");
38+
39+
// Create a table for a class
40+
Connection.CreateTable<ShopItem>();
41+
42+
// Delete all existing items in the table
43+
Connection.DeleteAll<ShopItem>();
44+
45+
// Insert items into the table
46+
Connection.Insert(new ShopItem() {
47+
ItemName = "Apple",
48+
Count = 10,
49+
});
50+
Connection.Insert(new ShopItem() {
51+
ItemName = "Banana",
52+
Count = 5,
53+
});
54+
55+
// Find one item in the table matching a predicate
56+
ShopItem? Apple = Connection.Find<ShopItem>(ShopItem => ShopItem.ItemName == "Apple");
57+
Assert.NotNull(Apple);
58+
59+
// Delete an item from the table
60+
Connection.Delete(Apple);
61+
62+
// Find several items in the table
63+
List<ShopItem> Bananas = Connection.Table<ShopItem>().Where(ShopItem => ShopItem.ItemName == "Banana").ToList();
64+
Assert.Single(Bananas);
65+
```

SQLiteSharp.Tests/UnitTest1.cs renamed to SQLiteSharp.Tests/ReadMeTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace SQLiteSharp.Tests;
22

3-
public class UnitTest1 {
3+
public class ReadMeTest {
44
[Fact]
55
public void Test1() {
66
// Open a database connection

0 commit comments

Comments
 (0)