-
Notifications
You must be signed in to change notification settings - Fork 1
/
ConnectorSeeder.cs
54 lines (50 loc) · 2.75 KB
/
ConnectorSeeder.cs
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
52
53
54
using Conductor.Data;
using Conductor.Models.Entities;
namespace Conductor.DbCli.Seed;
public class ConnectorSeeder : Seeder<Connector, ConductorContext>
{
public ConnectorSeeder(ConductorContext db) : base(db) { }
protected override async Task<List<Connector>> Generate()
{
List<Connector> connectors = new()
{
new()
{
Database = "AdventureWorks2019",
Server = @".\DevSql",
Name = "AdventureWorks-DevSql",
Queries = new List<Query>
{
new()
{
Name = "Count People",
Value = "SELECT COUNT(*) AS 'total'\nFROM [AdventureWorks2019].[Person].[Person]"
},
new()
{
Name = "Get People",
Value = "SELECT DISTINCT\n p.BusinessEntityId as 'legacyPersonId',\n p.LastName as 'lastName',\n p.FirstName as 'firstName',\n p.MiddleName as 'middleName'\nFROM [AdventureWorks2019].[Person].[Person] as p\nORDER BY p.LastName, p.FirstName\nOFFSET {{skip}} ROWS\nFETCH NEXT {{size}} ROWS ONLY"
},
new()
{
Name = "Search People",
Value = "SELECT TOP (20)\n p.BusinessEntityId as 'legacyPersonId',\n p.LastName as 'lastName',\n p.FirstName as 'firstName',\n p.MiddleName as 'middleName'\nFROM [AdventureWorks2019].[Person].[Person] as p\nWHERE p.LastName like '{{lastName}}%' and p.FirstName like '{{firstName}}%'\nORDER BY p.LastName, p.FirstName"
},
new()
{
Name = "Search Products",
Value = "SELECT top (20)\n p.Name as 'name',\n p.ProductNumber as 'name',\n p.ProductId as 'id'\nFROM [AdventureWorks2019].[Production].[Product] as p\nWHERE p.Name like '%{{search}}%'"
},
new()
{
Name = "Search Addresses",
Value = "SELECT TOP (20)\n a.AddressLine1 AS 'addressOne',\n a.AddressLine2 AS 'addressTwo',\n a.City AS 'city',\n s.[Name] AS 'state',\n a.PostalCode AS 'zip'\nFROM [AdventureWorks2019].[Person].[Address] AS a\nINNER JOIN [AdventureWorks2019].[Person].[StateProvince] AS s\nON a.StateProvinceID = s.StateProvinceID\nWHERE a.City like '%{{search}}%' OR s.[Name] like '%{{search}}%'\nORDER BY s.[Name], a.[City], a.[PostalCode]"
}
}
}
};
await db.Connectors.AddRangeAsync(connectors);
await db.SaveChangesAsync();
return connectors;
}
}