-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathSample.cs
More file actions
39 lines (33 loc) · 1.14 KB
/
Sample.cs
File metadata and controls
39 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using SharpData;
using SharpData.Filters;
using System;
using System.Linq;
using static SharpData.Schema.Column;
namespace SharpData.Sample {
public class Sample {
public void Start(IDataClient client) {
if (client.TableExists("users")) {
client.RemoveTable("users");
}
client.AddTable("users",
AutoIncrement("id").AsPrimaryKey(),
String("username", 50).NotNull(),
String("password", 50).NotNull()
);
client.AddUniqueKey("un_users", "users", "username");
client.Insert
.Into("users")
.Columns("username", "password")
.Values("foo", "bar");
var users = client.Select
.AllColumns()
.From("users")
.Where(Filter.Eq("username", "foo"))
.SkipTake(0, 1)
.Map<User>();
foreach (var user in users) {
Console.WriteLine("User: " + user.Username);
}
}
}
}