-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (36 loc) · 1.2 KB
/
Copy pathProgram.cs
File metadata and controls
51 lines (36 loc) · 1.2 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
40
41
42
43
44
45
46
47
48
49
50
51
using SquidStd.Database.Abstractions.Data.Entities;
using SquidStd.Database.Abstractions.Interfaces.Data;
using SquidStd.Database.Extensions;
using SquidStd.Services.Core.Services.Bootstrap;
var bootstrap = SquidStdBootstrap.Create(
new()
{
ConfigName = "squidstd",
RootDirectory = AppContext.BaseDirectory
}
);
#region step-1
bootstrap.ConfigureServices(container => container.RegisterDatabase());
await bootstrap.StartAsync();
#endregion
#region step-2
var products = bootstrap.Resolve<IDataAccess<Product>>();
await products.InsertAsync(new() { Name = "Squid Plushie", Price = 19.99m });
await products.InsertAsync(new() { Name = "Kraken Mug", Price = 12.50m });
var page = await products.GetPagedAsync(
1,
10,
orderBy: product => product.Price
);
Console.WriteLine($"Found {page.TotalCount} product(s) on page {page.Page}/{page.TotalPages}:");
foreach (var product in page.Items)
{
Console.WriteLine($" {product.Name} - {product.Price:C}");
}
#endregion
await bootstrap.StopAsync();
internal sealed class Product : BaseEntity
{
public string Name { get; set; } = string.Empty;
public decimal Price { get; set; }
}