diff --git a/dab-config.json b/dab-config.json deleted file mode 100644 index 9660247..0000000 --- a/dab-config.json +++ /dev/null @@ -1,368 +0,0 @@ -"entities": { - "Authors": { - "source": { - "object": "dbo.authors", - "type": "table" - }, - "mappings": { - "au_id": "AuId", - "au_lname": "AuLname", - "au_fname": "AuFname", - "phone": "Phone", - "address": "Address", - "city": "City", - "state": "State", - "zip": "Zip", - "contract": "Contract" - }, - "relationships": { - "FK__titleauth__au_id__44FF419A": { - "cardinality": "Many", - "target.entity": "Titleauthor" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Discounts": { - "source": { - "object": "dbo.discounts", - "type": "table" - }, - "mappings": { - "discounttype": "Discounttype", - "stor_id": "StorId", - "lowqty": "Lowqty", - "highqty": "Highqty", - "discount": "Discount" - }, - "relationships": { - "FK__discounts__stor___4F7CD00D": { - "cardinality": "Many", - "target.entity": "Stores" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Stores": { - "source": { - "object": "dbo.stores", - "type": "table" - }, - "mappings": { - "stor_id": "StorId", - "stor_name": "StorName", - "stor_address": "StorAddress", - "city": "City", - "state": "State", - "zip": "Zip" - }, - "relationships": { - "FK__discounts__stor___4F7CD00D": { - "cardinality": "Many", - "target.entity": "Discounts" - }, - "FK__sales__stor_id__4AB81AF0": { - "cardinality": "Many", - "target.entity": "Sales" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Employee": { - "source": { - "object": "dbo.employee", - "type": "table" - }, - "mappings": { - "emp_id": "EmpId", - "fname": "Fname", - "minit": "Minit", - "lname": "Lname", - "job_id": "JobId", - "job_lvl": "JobLvl", - "pub_id": "PubId", - "hire_date": "HireDate" - }, - "relationships": { - "FK__employee__job_id__5BE2A6F2": { - "cardinality": "One", - "target.entity": "Jobs" - }, - "FK__employee__pub_id__5EBF139D": { - "cardinality": "One", - "target.entity": "Publishers" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Jobs": { - "source": { - "object": "dbo.jobs", - "type": "table" - }, - "mappings": { - "job_id": "JobId", - "job_desc": "JobDesc", - "min_lvl": "MinLvl", - "max_lvl": "MaxLvl" - }, - "relationships": { - "FK__employee__job_id__5BE2A6F2": { - "cardinality": "Many", - "target.entity": "Employee" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Publishers": { - "source": { - "object": "dbo.publishers", - "type": "table" - }, - "mappings": { - "pub_id": "PubId", - "pub_name": "PubName", - "city": "City", - "state": "State", - "country": "Country" - }, - "relationships": { - "FK__employee__pub_id__5EBF139D": { - "cardinality": "Many", - "target.entity": "Employee" - }, - "FK__pub_info__pub_id__571DF1D5": { - "cardinality": "One", - "target.entity": "PubInfo" - }, - "FK__titles__pub_id__412EB0B6": { - "cardinality": "Many", - "target.entity": "Titles" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "PubInfo": { - "source": { - "object": "dbo.pub_info", - "type": "table" - }, - "mappings": { - "pub_id": "PubId", - "logo": "Logo", - "pr_info": "PrInfo" - }, - "relationships": { - "FK__pub_info__pub_id__571DF1D5": { - "cardinality": "One", - "target.entity": "Publishers" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Roysched": { - "source": { - "object": "dbo.roysched", - "type": "table" - }, - "mappings": { - "title_id": "TitleId", - "lorange": "Lorange", - "hirange": "Hirange", - "royalty": "Royalty" - }, - "relationships": { - "FK__roysched__title___4D94879B": { - "cardinality": "One", - "target.entity": "Titles" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Titles": { - "source": { - "object": "dbo.titles", - "type": "table" - }, - "mappings": { - "title_id": "TitleId", - "title": "Title", - "type": "Type", - "pub_id": "PubId", - "price": "Price", - "advance": "Advance", - "royalty": "Royalty", - "ytd_sales": "YtdSales", - "notes": "Notes", - "pubdate": "Pubdate" - }, - "relationships": { - "FK__roysched__title___4D94879B": { - "cardinality": "Many", - "target.entity": "Roysched" - }, - "FK__sales__title_id__4BAC3F29": { - "cardinality": "Many", - "target.entity": "Sales" - }, - "FK__titleauth__title__45F365D3": { - "cardinality": "Many", - "target.entity": "Titleauthor" - }, - "FK__titles__pub_id__412EB0B6": { - "cardinality": "Many", - "target.entity": "Publishers" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Sales": { - "source": { - "object": "dbo.sales", - "type": "table" - }, - "mappings": { - "stor_id": "StorId", - "ord_num": "OrdNum", - "ord_date": "OrdDate", - "qty": "Qty", - "payterms": "Payterms", - "title_id": "TitleId" - }, - "relationships": { - "FK__sales__stor_id__4AB81AF0": { - "cardinality": "One", - "target.entity": "Stores" - }, - "FK__sales__title_id__4BAC3F29": { - "cardinality": "One", - "target.entity": "Titles" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Titleauthor": { - "source": { - "object": "dbo.titleauthor", - "type": "table" - }, - "mappings": { - "au_id": "AuId", - "title_id": "TitleId", - "au_ord": "AuOrd", - "royaltyper": "Royaltyper" - }, - "relationships": { - "FK__titleauth__au_id__44FF419A": { - "cardinality": "One", - "target.entity": "Authors" - }, - "FK__titleauth__title__45F365D3": { - "cardinality": "One", - "target.entity": "Titles" - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, - "Titleview": { - "source": { - "object": "dbo.titleview", - "type": "view" - }, - "mappings": { - "title": "Title", - "au_ord": "AuOrd", - "au_lname": "AuLname", - "price": "Price", - "ytd_sales": "YtdSales", - "pub_id": "PubId" - }, - "relationships": { - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - }] - }] - }, -} diff --git a/dab-config.yaml b/dab-config.yaml deleted file mode 100644 index f3ab559..0000000 --- a/dab-config.yaml +++ /dev/null @@ -1,895 +0,0 @@ -EntityClass: Authors -ContextProperty: -TableSchema: 'dbo' -TableName: 'authors' -IsView: False -Properties: - - PropertyName: AuId - ColumnName: 'au_id' - StoreType: varchar(11) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 11 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: AuLname - ColumnName: 'au_lname' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: AuFname - ColumnName: 'au_fname' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Phone - ColumnName: 'phone' - StoreType: char(12) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 12 - Default: '('UNKNOWN')' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Address - ColumnName: 'address' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: City - ColumnName: 'city' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: State - ColumnName: 'state' - StoreType: char(2) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 2 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Zip - ColumnName: 'zip' - StoreType: char(5) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 5 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Contract - ColumnName: 'contract' - StoreType: bit - NativeType: 'bit' - DataType: Boolean - SystemType: Boolean - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Discounts -ContextProperty: -TableSchema: 'dbo' -TableName: 'discounts' -IsView: False -Properties: - - PropertyName: Discounttype - ColumnName: 'discounttype' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: StorId - ColumnName: 'stor_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: Lowqty - ColumnName: 'lowqty' - StoreType: smallint - NativeType: 'smallint' - DataType: Int16 - SystemType: Int16 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Highqty - ColumnName: 'highqty' - StoreType: smallint - NativeType: 'smallint' - DataType: Int16 - SystemType: Int16 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Discount - ColumnName: 'discount' - StoreType: decimal(4,2) - NativeType: '@decimal' - DataType: Decimal - SystemType: Decimal - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Stores -ContextProperty: -TableSchema: 'dbo' -TableName: 'stores' -IsView: False -Properties: - - PropertyName: StorId - ColumnName: 'stor_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: StorName - ColumnName: 'stor_name' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: StorAddress - ColumnName: 'stor_address' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: City - ColumnName: 'city' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: State - ColumnName: 'state' - StoreType: char(2) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 2 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Zip - ColumnName: 'zip' - StoreType: char(5) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 5 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Employee -ContextProperty: -TableSchema: 'dbo' -TableName: 'employee' -IsView: False -Properties: - - PropertyName: EmpId - ColumnName: 'emp_id' - StoreType: char(9) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 9 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Fname - ColumnName: 'fname' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Minit - ColumnName: 'minit' - StoreType: char(1) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 1 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Lname - ColumnName: 'lname' - StoreType: varchar(30) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 30 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: JobId - ColumnName: 'job_id' - StoreType: smallint - NativeType: 'smallint' - DataType: Int16 - SystemType: Int16 - Default: '((1))' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: JobLvl - ColumnName: 'job_lvl' - StoreType: tinyint - NativeType: 'tinyint' - DataType: Byte - SystemType: Byte - Default: '((10))' - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: PubId - ColumnName: 'pub_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - Default: '('9952')' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: HireDate - ColumnName: 'hire_date' - StoreType: datetime - NativeType: 'datetime' - DataType: DateTime - SystemType: DateTime - Default: '(getdate())' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Jobs -ContextProperty: -TableSchema: 'dbo' -TableName: 'jobs' -IsView: False -Properties: - - PropertyName: JobId - ColumnName: 'job_id' - StoreType: smallint - NativeType: 'smallint' - DataType: Int16 - SystemType: Int16 - ValueGenerated: OnAdd - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: JobDesc - ColumnName: 'job_desc' - StoreType: varchar(50) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 50 - Default: '('New Position - title not formalized yet')' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: MinLvl - ColumnName: 'min_lvl' - StoreType: tinyint - NativeType: 'tinyint' - DataType: Byte - SystemType: Byte - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: MaxLvl - ColumnName: 'max_lvl' - StoreType: tinyint - NativeType: 'tinyint' - DataType: Byte - SystemType: Byte - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Publishers -ContextProperty: -TableSchema: 'dbo' -TableName: 'publishers' -IsView: False -Properties: - - PropertyName: PubId - ColumnName: 'pub_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: PubName - ColumnName: 'pub_name' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: City - ColumnName: 'city' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: State - ColumnName: 'state' - StoreType: char(2) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 2 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Country - ColumnName: 'country' - StoreType: varchar(30) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 30 - Default: '('USA')' - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: PubInfo -ContextProperty: -TableSchema: 'dbo' -TableName: 'pub_info' -IsView: False -Properties: - - PropertyName: PubId - ColumnName: 'pub_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: Logo - ColumnName: 'logo' - StoreType: image - NativeType: 'image' - DataType: Binary - SystemType: Byte[] - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: PrInfo - ColumnName: 'pr_info' - StoreType: text - NativeType: 'text' - DataType: AnsiString - SystemType: String - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Roysched -ContextProperty: -TableSchema: 'dbo' -TableName: 'roysched' -IsView: False -Properties: - - PropertyName: TitleId - ColumnName: 'title_id' - StoreType: varchar(6) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 6 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: Lorange - ColumnName: 'lorange' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Hirange - ColumnName: 'hirange' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Royalty - ColumnName: 'royalty' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Titles -ContextProperty: -TableSchema: 'dbo' -TableName: 'titles' -IsView: False -Properties: - - PropertyName: TitleId - ColumnName: 'title_id' - StoreType: varchar(6) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 6 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Title - ColumnName: 'title' - StoreType: varchar(80) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 80 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Type - ColumnName: 'type' - StoreType: char(12) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 12 - Default: '('UNDECIDED')' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: PubId - ColumnName: 'pub_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: Price - ColumnName: 'price' - StoreType: money - NativeType: 'money' - DataType: Currency - SystemType: Decimal - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Advance - ColumnName: 'advance' - StoreType: money - NativeType: 'money' - DataType: Currency - SystemType: Decimal - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Royalty - ColumnName: 'royalty' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: YtdSales - ColumnName: 'ytd_sales' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Notes - ColumnName: 'notes' - StoreType: varchar(200) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 200 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Pubdate - ColumnName: 'pubdate' - StoreType: datetime - NativeType: 'datetime' - DataType: DateTime - SystemType: DateTime - Default: '(getdate())' - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Sales -ContextProperty: -TableSchema: 'dbo' -TableName: 'sales' -IsView: False -Properties: - - PropertyName: StorId - ColumnName: 'stor_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: OrdNum - ColumnName: 'ord_num' - StoreType: varchar(20) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 20 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: OrdDate - ColumnName: 'ord_date' - StoreType: datetime - NativeType: 'datetime' - DataType: DateTime - SystemType: DateTime - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Qty - ColumnName: 'qty' - StoreType: smallint - NativeType: 'smallint' - DataType: Int16 - SystemType: Int16 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Payterms - ColumnName: 'payterms' - StoreType: varchar(12) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 12 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: TitleId - ColumnName: 'title_id' - StoreType: varchar(6) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 6 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: True - IsRowVersion: False - IsUnique: False -EntityClass: Titleauthor -ContextProperty: -TableSchema: 'dbo' -TableName: 'titleauthor' -IsView: False -Properties: - - PropertyName: AuId - ColumnName: 'au_id' - StoreType: varchar(11) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 11 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: TitleId - ColumnName: 'title_id' - StoreType: varchar(6) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 6 - IsNullable: False - IsPrimaryKey: True - IsForeignKey: True - IsRowVersion: False - IsUnique: False - - PropertyName: AuOrd - ColumnName: 'au_ord' - StoreType: tinyint - NativeType: 'tinyint' - DataType: Byte - SystemType: Byte - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Royaltyper - ColumnName: 'royaltyper' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False -EntityClass: Titleview -ContextProperty: -TableSchema: 'dbo' -TableName: 'titleview' -IsView: True -Properties: - - PropertyName: Title - ColumnName: 'title' - StoreType: varchar(80) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 80 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: AuOrd - ColumnName: 'au_ord' - StoreType: tinyint - NativeType: 'tinyint' - DataType: Byte - SystemType: Byte - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: AuLname - ColumnName: 'au_lname' - StoreType: varchar(40) - NativeType: 'varchar' - DataType: AnsiString - SystemType: String - Size: 40 - IsNullable: False - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: Price - ColumnName: 'price' - StoreType: money - NativeType: 'money' - DataType: Currency - SystemType: Decimal - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: YtdSales - ColumnName: 'ytd_sales' - StoreType: @int - NativeType: '@int' - DataType: Int32 - SystemType: Int32 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False - - PropertyName: PubId - ColumnName: 'pub_id' - StoreType: char(4) - NativeType: '@char' - DataType: AnsiStringFixedLength - SystemType: String - Size: 4 - IsNullable: True - IsPrimaryKey: False - IsForeignKey: False - IsRowVersion: False - IsUnique: False diff --git a/src/DbApiBuilderEntityGenerator.Core/DbApiBuilderEntityGenerator.Core.csproj b/src/DbApiBuilderEntityGenerator.Core/DbApiBuilderEntityGenerator.Core.csproj index c417bfb..553574b 100644 --- a/src/DbApiBuilderEntityGenerator.Core/DbApiBuilderEntityGenerator.Core.csproj +++ b/src/DbApiBuilderEntityGenerator.Core/DbApiBuilderEntityGenerator.Core.csproj @@ -32,7 +32,6 @@ - diff --git a/src/DbApiBuilderEntityGenerator.Core/Scripts/ScriptTemplateBase.cs b/src/DbApiBuilderEntityGenerator.Core/Scripts/ScriptTemplateBase.cs index 611ccbc..c684802 100644 --- a/src/DbApiBuilderEntityGenerator.Core/Scripts/ScriptTemplateBase.cs +++ b/src/DbApiBuilderEntityGenerator.Core/Scripts/ScriptTemplateBase.cs @@ -95,7 +95,7 @@ protected Script LoadScript(string scriptPath) if (scriptPath.IsNullOrEmpty()) { scriptContent = Assembly.GetExecutingAssembly() - .ReadResourceAsync("DbApiBuilderEntityGenerator.Core.template.dab-config1.csx") + .ReadResourceAsync("DbApiBuilderEntityGenerator.Core.template.dab-config.csx") .Result; } diff --git a/src/DbApiBuilderEntityGenerator.Core/template/dab-config.csx b/src/DbApiBuilderEntityGenerator.Core/template/dab-config.csx index 5afe8c2..c7e340b 100644 --- a/src/DbApiBuilderEntityGenerator.Core/template/dab-config.csx +++ b/src/DbApiBuilderEntityGenerator.Core/template/dab-config.csx @@ -1,23 +1,113 @@ public string WriteCode() { CodeBuilder.Clear(); + // start entities object + CodeBuilder.AppendLine("\"entities\": {"); foreach (var entity in EntityContext.Entities) { - CodeBuilder.Append("EntityClass: ").Append(entity.EntityClass.ToSafeName()).AppendLine(); - - CodeBuilder.Append("ContextProperty: ").Append(entity.ContextProperty.ToSafeName()).AppendLine(); - - CodeBuilder.Append("TableSchema: '").Append(entity.TableSchema.ToSafeName()).AppendLine("'"); - CodeBuilder.Append("TableName: '").Append(entity.TableName.ToSafeName()).AppendLine("'"); - - - CodeBuilder.Append("IsView: ").Append(entity.IsView.ToString()).AppendLine(); - - CodeBuilder.Append("Properties:").AppendLine(); using (CodeBuilder.Indent()) - GenerateProperties(entity); + { + // start entity object + CodeBuilder.Append("\"").Append(entity.EntityClass.ToSafeName()).Append("\": {").AppendLine(); + + using (CodeBuilder.Indent()) + { + // start source object + CodeBuilder.Append("\"source\": {").AppendLine(); + CodeBuilder.Append("\"object\": \"").Append(entity.TableSchema.ToSafeName()).Append(".").Append(entity.TableName.ToSafeName()).Append("\",").AppendLine(); + if (entity.IsView) + { + CodeBuilder.Append("\"type\": \"view\"").AppendLine(); + } + else + { + CodeBuilder.Append("\"type\": \"table\"").AppendLine(); + } + + // end source object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start mappings object + CodeBuilder.Append("\"mappings\": {").AppendLine(); + + var propertyCount = entity.Properties.Count - 1; + int count = 0; + + foreach (var property in entity.Properties) + { + CodeBuilder.Append("\"").Append(property.ColumnName.ToSafeName()).Append("\": "); + if (count == propertyCount) + { + CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\"").AppendLine(); + } + else + { + CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\",").AppendLine(); + } + count++; + } + // end mappings object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start relationships object + CodeBuilder.Append("\"relationships\": {").AppendLine(); + var relCount = 0; + var relationshipCount = entity.Relationships.Count - 1; + using (CodeBuilder.Indent()) + { + foreach (var relationship in entity.Relationships) + { + CodeBuilder.Append("\"").Append(relationship.RelationshipName.ToSafeName()).Append("\": {").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"cardinality\": \"").Append(relationship.Cardinality.ToString().ToSafeName()).Append("\",").AppendLine(); + CodeBuilder.Append("\"target.entity\": \"").Append(relationship.PrimaryEntity.EntityClass.ToSafeName().ToSafeName()).Append("\"").AppendLine(); + } + CodeBuilder.Append("}"); + if (relCount != relationshipCount) + { + CodeBuilder.Append(","); + } + relCount++; + CodeBuilder.AppendLine(); + } + } + // end relationships object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start permissions object + CodeBuilder.Append("\"permissions\": [").AppendLine(); + CodeBuilder.Append("{").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"role\": \"anonymous\",").AppendLine(); + CodeBuilder.Append("\"actions\": [").AppendLine(); + CodeBuilder.Append("{").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"action\": \"*\"").AppendLine(); + } + CodeBuilder.Append("}]").AppendLine(); + + } + CodeBuilder.Append("}]").AppendLine(); + // end permissions object + } + // end entity object + CodeBuilder.Append("},").AppendLine(); + } } - + // end entities object + CodeBuilder.Append("}").AppendLine(); return CodeBuilder.ToString(); } diff --git a/src/DbApiBuilderEntityGenerator.Core/template/dab-config1.csx b/src/DbApiBuilderEntityGenerator.Core/template/dab-config1.csx deleted file mode 100644 index c7e340b..0000000 --- a/src/DbApiBuilderEntityGenerator.Core/template/dab-config1.csx +++ /dev/null @@ -1,155 +0,0 @@ -public string WriteCode() -{ - CodeBuilder.Clear(); - // start entities object - CodeBuilder.AppendLine("\"entities\": {"); - foreach (var entity in EntityContext.Entities) - { - using (CodeBuilder.Indent()) - { - // start entity object - CodeBuilder.Append("\"").Append(entity.EntityClass.ToSafeName()).Append("\": {").AppendLine(); - - using (CodeBuilder.Indent()) - { - // start source object - CodeBuilder.Append("\"source\": {").AppendLine(); - CodeBuilder.Append("\"object\": \"").Append(entity.TableSchema.ToSafeName()).Append(".").Append(entity.TableName.ToSafeName()).Append("\",").AppendLine(); - if (entity.IsView) - { - CodeBuilder.Append("\"type\": \"view\"").AppendLine(); - } - else - { - CodeBuilder.Append("\"type\": \"table\"").AppendLine(); - } - - // end source object - CodeBuilder.Append("},").AppendLine(); - } - - using (CodeBuilder.Indent()) - { - // start mappings object - CodeBuilder.Append("\"mappings\": {").AppendLine(); - - var propertyCount = entity.Properties.Count - 1; - int count = 0; - - foreach (var property in entity.Properties) - { - CodeBuilder.Append("\"").Append(property.ColumnName.ToSafeName()).Append("\": "); - if (count == propertyCount) - { - CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\"").AppendLine(); - } - else - { - CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\",").AppendLine(); - } - count++; - } - // end mappings object - CodeBuilder.Append("},").AppendLine(); - } - - using (CodeBuilder.Indent()) - { - // start relationships object - CodeBuilder.Append("\"relationships\": {").AppendLine(); - var relCount = 0; - var relationshipCount = entity.Relationships.Count - 1; - using (CodeBuilder.Indent()) - { - foreach (var relationship in entity.Relationships) - { - CodeBuilder.Append("\"").Append(relationship.RelationshipName.ToSafeName()).Append("\": {").AppendLine(); - using (CodeBuilder.Indent()) - { - CodeBuilder.Append("\"cardinality\": \"").Append(relationship.Cardinality.ToString().ToSafeName()).Append("\",").AppendLine(); - CodeBuilder.Append("\"target.entity\": \"").Append(relationship.PrimaryEntity.EntityClass.ToSafeName().ToSafeName()).Append("\"").AppendLine(); - } - CodeBuilder.Append("}"); - if (relCount != relationshipCount) - { - CodeBuilder.Append(","); - } - relCount++; - CodeBuilder.AppendLine(); - } - } - // end relationships object - CodeBuilder.Append("},").AppendLine(); - } - - using (CodeBuilder.Indent()) - { - // start permissions object - CodeBuilder.Append("\"permissions\": [").AppendLine(); - CodeBuilder.Append("{").AppendLine(); - using (CodeBuilder.Indent()) - { - CodeBuilder.Append("\"role\": \"anonymous\",").AppendLine(); - CodeBuilder.Append("\"actions\": [").AppendLine(); - CodeBuilder.Append("{").AppendLine(); - using (CodeBuilder.Indent()) - { - CodeBuilder.Append("\"action\": \"*\"").AppendLine(); - } - CodeBuilder.Append("}]").AppendLine(); - - } - CodeBuilder.Append("}]").AppendLine(); - // end permissions object - } - // end entity object - CodeBuilder.Append("},").AppendLine(); - } - } - // end entities object - CodeBuilder.Append("}").AppendLine(); - return CodeBuilder.ToString(); -} - -private void GenerateProperties(Entity entity) -{ - foreach (var property in entity.Properties) - { - CodeBuilder.Append("- PropertyName: ").Append(property.PropertyName.ToSafeName()).AppendLine(); - CodeBuilder.Append(" ColumnName: '").Append(property.ColumnName.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" StoreType: ").Append(property.StoreType.ToSafeName()).AppendLine(); - CodeBuilder.Append(" NativeType: '").Append(property.NativeType.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" DataType: ").Append(property.DataType.ToString()).AppendLine(); - CodeBuilder.Append(" SystemType: ").Append(property.SystemType.Name).AppendLine(); - - if (property.Size != null) - CodeBuilder.Append(" Size: ").Append(property.Size.ToString()).AppendLine(); - - if (property.Default != null) - CodeBuilder.Append(" Default: '").Append(property.Default.ToSafeName()).AppendLine("'"); - - if (property.ValueGenerated != null) - CodeBuilder.Append(" ValueGenerated: ").Append(property.ValueGenerated.ToString()).AppendLine(); - - if (property.IsNullable != null) - CodeBuilder.Append(" IsNullable: ").Append(property.IsNullable.ToString()).AppendLine(); - - if (property.IsPrimaryKey != null) - CodeBuilder.Append(" IsPrimaryKey: ").Append(property.IsPrimaryKey.ToString()).AppendLine(); - - if (property.IsForeignKey != null) - CodeBuilder.Append(" IsForeignKey: ").Append(property.IsForeignKey.ToString()).AppendLine(); - - if (property.IsReadOnly != null) - CodeBuilder.Append(" IsReadOnly: ").Append(property.IsReadOnly.ToString()).AppendLine(); - - if (property.IsRowVersion != null) - CodeBuilder.Append(" IsRowVersion: ").Append(property.IsRowVersion.ToString()).AppendLine(); - - if (property.IsUnique != null) - CodeBuilder.Append(" IsUnique: ").Append(property.IsUnique.ToString()).AppendLine(); - } -} - -// run script -WriteCode() diff --git a/src/DbApiBuilderEntityGenerator/template/dab-config.csx b/src/DbApiBuilderEntityGenerator/template/dab-config.csx index 5afe8c2..c7e340b 100644 --- a/src/DbApiBuilderEntityGenerator/template/dab-config.csx +++ b/src/DbApiBuilderEntityGenerator/template/dab-config.csx @@ -1,23 +1,113 @@ public string WriteCode() { CodeBuilder.Clear(); + // start entities object + CodeBuilder.AppendLine("\"entities\": {"); foreach (var entity in EntityContext.Entities) { - CodeBuilder.Append("EntityClass: ").Append(entity.EntityClass.ToSafeName()).AppendLine(); - - CodeBuilder.Append("ContextProperty: ").Append(entity.ContextProperty.ToSafeName()).AppendLine(); - - CodeBuilder.Append("TableSchema: '").Append(entity.TableSchema.ToSafeName()).AppendLine("'"); - CodeBuilder.Append("TableName: '").Append(entity.TableName.ToSafeName()).AppendLine("'"); - - - CodeBuilder.Append("IsView: ").Append(entity.IsView.ToString()).AppendLine(); - - CodeBuilder.Append("Properties:").AppendLine(); using (CodeBuilder.Indent()) - GenerateProperties(entity); + { + // start entity object + CodeBuilder.Append("\"").Append(entity.EntityClass.ToSafeName()).Append("\": {").AppendLine(); + + using (CodeBuilder.Indent()) + { + // start source object + CodeBuilder.Append("\"source\": {").AppendLine(); + CodeBuilder.Append("\"object\": \"").Append(entity.TableSchema.ToSafeName()).Append(".").Append(entity.TableName.ToSafeName()).Append("\",").AppendLine(); + if (entity.IsView) + { + CodeBuilder.Append("\"type\": \"view\"").AppendLine(); + } + else + { + CodeBuilder.Append("\"type\": \"table\"").AppendLine(); + } + + // end source object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start mappings object + CodeBuilder.Append("\"mappings\": {").AppendLine(); + + var propertyCount = entity.Properties.Count - 1; + int count = 0; + + foreach (var property in entity.Properties) + { + CodeBuilder.Append("\"").Append(property.ColumnName.ToSafeName()).Append("\": "); + if (count == propertyCount) + { + CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\"").AppendLine(); + } + else + { + CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\",").AppendLine(); + } + count++; + } + // end mappings object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start relationships object + CodeBuilder.Append("\"relationships\": {").AppendLine(); + var relCount = 0; + var relationshipCount = entity.Relationships.Count - 1; + using (CodeBuilder.Indent()) + { + foreach (var relationship in entity.Relationships) + { + CodeBuilder.Append("\"").Append(relationship.RelationshipName.ToSafeName()).Append("\": {").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"cardinality\": \"").Append(relationship.Cardinality.ToString().ToSafeName()).Append("\",").AppendLine(); + CodeBuilder.Append("\"target.entity\": \"").Append(relationship.PrimaryEntity.EntityClass.ToSafeName().ToSafeName()).Append("\"").AppendLine(); + } + CodeBuilder.Append("}"); + if (relCount != relationshipCount) + { + CodeBuilder.Append(","); + } + relCount++; + CodeBuilder.AppendLine(); + } + } + // end relationships object + CodeBuilder.Append("},").AppendLine(); + } + + using (CodeBuilder.Indent()) + { + // start permissions object + CodeBuilder.Append("\"permissions\": [").AppendLine(); + CodeBuilder.Append("{").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"role\": \"anonymous\",").AppendLine(); + CodeBuilder.Append("\"actions\": [").AppendLine(); + CodeBuilder.Append("{").AppendLine(); + using (CodeBuilder.Indent()) + { + CodeBuilder.Append("\"action\": \"*\"").AppendLine(); + } + CodeBuilder.Append("}]").AppendLine(); + + } + CodeBuilder.Append("}]").AppendLine(); + // end permissions object + } + // end entity object + CodeBuilder.Append("},").AppendLine(); + } } - + // end entities object + CodeBuilder.Append("}").AppendLine(); return CodeBuilder.ToString(); } diff --git a/template/dab-config.csx b/template/dab-config.csx deleted file mode 100644 index 5afe8c2..0000000 --- a/template/dab-config.csx +++ /dev/null @@ -1,65 +0,0 @@ -public string WriteCode() -{ - CodeBuilder.Clear(); - foreach (var entity in EntityContext.Entities) - { - CodeBuilder.Append("EntityClass: ").Append(entity.EntityClass.ToSafeName()).AppendLine(); - - CodeBuilder.Append("ContextProperty: ").Append(entity.ContextProperty.ToSafeName()).AppendLine(); - - CodeBuilder.Append("TableSchema: '").Append(entity.TableSchema.ToSafeName()).AppendLine("'"); - CodeBuilder.Append("TableName: '").Append(entity.TableName.ToSafeName()).AppendLine("'"); - - - CodeBuilder.Append("IsView: ").Append(entity.IsView.ToString()).AppendLine(); - - CodeBuilder.Append("Properties:").AppendLine(); - using (CodeBuilder.Indent()) - GenerateProperties(entity); - } - - return CodeBuilder.ToString(); -} - -private void GenerateProperties(Entity entity) -{ - foreach (var property in entity.Properties) - { - CodeBuilder.Append("- PropertyName: ").Append(property.PropertyName.ToSafeName()).AppendLine(); - CodeBuilder.Append(" ColumnName: '").Append(property.ColumnName.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" StoreType: ").Append(property.StoreType.ToSafeName()).AppendLine(); - CodeBuilder.Append(" NativeType: '").Append(property.NativeType.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" DataType: ").Append(property.DataType.ToString()).AppendLine(); - CodeBuilder.Append(" SystemType: ").Append(property.SystemType.Name).AppendLine(); - - if (property.Size != null) - CodeBuilder.Append(" Size: ").Append(property.Size.ToString()).AppendLine(); - - if (property.Default != null) - CodeBuilder.Append(" Default: '").Append(property.Default.ToSafeName()).AppendLine("'"); - - if (property.ValueGenerated != null) - CodeBuilder.Append(" ValueGenerated: ").Append(property.ValueGenerated.ToString()).AppendLine(); - - if (property.IsNullable != null) - CodeBuilder.Append(" IsNullable: ").Append(property.IsNullable.ToString()).AppendLine(); - - if (property.IsPrimaryKey != null) - CodeBuilder.Append(" IsPrimaryKey: ").Append(property.IsPrimaryKey.ToString()).AppendLine(); - - if (property.IsForeignKey != null) - CodeBuilder.Append(" IsForeignKey: ").Append(property.IsForeignKey.ToString()).AppendLine(); - - if (property.IsReadOnly != null) - CodeBuilder.Append(" IsReadOnly: ").Append(property.IsReadOnly.ToString()).AppendLine(); - - if (property.IsRowVersion != null) - CodeBuilder.Append(" IsRowVersion: ").Append(property.IsRowVersion.ToString()).AppendLine(); - - if (property.IsUnique != null) - CodeBuilder.Append(" IsUnique: ").Append(property.IsUnique.ToString()).AppendLine(); - } -} - -// run script -WriteCode() diff --git a/template/dab-config1.csx b/template/dab-config1.csx deleted file mode 100644 index 0ae5c54..0000000 --- a/template/dab-config1.csx +++ /dev/null @@ -1,135 +0,0 @@ -public string WriteCode() -{ - CodeBuilder.Clear(); - // start entities object - CodeBuilder.AppendLine("\"entities\": {"); - foreach (var entity in EntityContext.Entities) - { - using (CodeBuilder.Indent()) - { - // start entity object - CodeBuilder.Append("\"").Append(entity.EntityClass.ToSafeName()).Append("\": {").AppendLine(); - - using (CodeBuilder.Indent()) - { - // start source object - CodeBuilder.Append("\"source\": {").AppendLine(); - CodeBuilder.Append("\"object\": \"").Append(entity.TableSchema.ToSafeName()).Append(".").Append(entity.TableName.ToSafeName()).Append("\",").AppendLine(); - if (entity.IsView) - { - CodeBuilder.Append("\"type\": \"view\"").AppendLine(); - } - else - { - CodeBuilder.Append("\"type\": \"table\"").AppendLine(); - } - - // end source object - CodeBuilder.Append("},").AppendLine(); - } - - using (CodeBuilder.Indent()) - { - // start mappings object - CodeBuilder.Append("\"mappings\": {").AppendLine(); - - var propertyCount = entity.Properties.Count - 1; - int count = 0; - - foreach (var property in entity.Properties) - { - CodeBuilder.Append("\"").Append(property.ColumnName.ToSafeName()).Append("\": "); - if (count == propertyCount) - { - CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\"").AppendLine(); - } - else - { - CodeBuilder.Append("\"").Append(property.PropertyName.ToSafeName()).Append("\",").AppendLine(); - } - count++; - } - // end mappings object - CodeBuilder.Append("}").AppendLine(); - } - - using (CodeBuilder.Indent()) - { - // start relationships object - CodeBuilder.Append("\"relationships\": {").AppendLine(); - foreach (var relationship in entity.Relationships) - { - CodeBuilder.Append("\"").Append(relationship.RelationshipName.ToSafeName()).Append("\":{").AppendLine(); - using (CodeBuilder.Indent()) - { - CodeBuilder.Append("\"cardinality\": \"").Append(relationship.Cardinality.ToString().ToSafeName()).Append("\",").AppendLine(); - CodeBuilder.Append("\"target.entity\": \"").Append(relationship.PrimaryEntity.EntityClass.ToSafeName().ToSafeName()).Append("\",").AppendLine(); - } - // end relationships object - CodeBuilder.Append("}").AppendLine(); - } - } - - using (CodeBuilder.Indent()) - { - // start permissions object - CodeBuilder.Append("\"permissions\": [").AppendLine(); - CodeBuilder.Append("{").AppendLine(); - using (CodeBuilder.Indent()) - { - CodeBuilder.Append("\"role\": \"anonymous\"").AppendLine(); - } - CodeBuilder.Append("}").AppendLine(); - // end permissions object - } - } - // end entity object - CodeBuilder.Append("}").AppendLine(); - } - // end entities object - CodeBuilder.Append("}").AppendLine(); - return CodeBuilder.ToString(); -} - -private void GenerateProperties(Entity entity) -{ - foreach (var property in entity.Properties) - { - CodeBuilder.Append("- PropertyName: ").Append(property.PropertyName.ToSafeName()).AppendLine(); - CodeBuilder.Append(" ColumnName: '").Append(property.ColumnName.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" StoreType: ").Append(property.StoreType.ToSafeName()).AppendLine(); - CodeBuilder.Append(" NativeType: '").Append(property.NativeType.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" DataType: ").Append(property.DataType.ToString()).AppendLine(); - CodeBuilder.Append(" SystemType: ").Append(property.SystemType.Name).AppendLine(); - - if (property.Size != null) - CodeBuilder.Append(" Size: ").Append(property.Size.ToString()).AppendLine(); - - if (property.Default != null) - CodeBuilder.Append(" Default: '").Append(property.Default.ToSafeName()).AppendLine("'"); - - if (property.ValueGenerated != null) - CodeBuilder.Append(" ValueGenerated: ").Append(property.ValueGenerated.ToString()).AppendLine(); - - if (property.IsNullable != null) - CodeBuilder.Append(" IsNullable: ").Append(property.IsNullable.ToString()).AppendLine(); - - if (property.IsPrimaryKey != null) - CodeBuilder.Append(" IsPrimaryKey: ").Append(property.IsPrimaryKey.ToString()).AppendLine(); - - if (property.IsForeignKey != null) - CodeBuilder.Append(" IsForeignKey: ").Append(property.IsForeignKey.ToString()).AppendLine(); - - if (property.IsReadOnly != null) - CodeBuilder.Append(" IsReadOnly: ").Append(property.IsReadOnly.ToString()).AppendLine(); - - if (property.IsRowVersion != null) - CodeBuilder.Append(" IsRowVersion: ").Append(property.IsRowVersion.ToString()).AppendLine(); - - if (property.IsUnique != null) - CodeBuilder.Append(" IsUnique: ").Append(property.IsUnique.ToString()).AppendLine(); - } -} - -// run script -WriteCode() diff --git a/tests/TestDatabase/Dockerfile b/tests/TestDatabase/Dockerfile deleted file mode 100644 index 9dae886..0000000 --- a/tests/TestDatabase/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mcr.microsoft.com/mssql/server:2022-latest -ARG BAK_FILE -ARG SQL_FILE -ENV MSSQL_SA_PASSWORD=Test_123_Test -EXPOSE 1433 -WORKDIR / -COPY $SQL_FILE ./Tracker.sql -COPY ./install.sh . -#COPY ./startup.sh . -#CMD /bin/bash ./startup.sh \ No newline at end of file diff --git a/tests/TestDatabase/Script002.Tracker.Data.sql b/tests/TestDatabase/Script002.Tracker.Data.sql deleted file mode 100644 index 00b466f..0000000 --- a/tests/TestDatabase/Script002.Tracker.Data.sql +++ /dev/null @@ -1,93 +0,0 @@ --- Table [dbo].[Priority] data - -MERGE INTO [dbo].[Priority] AS t -USING -( - VALUES - (1, 'High', 'High Priority', 1, 1), - (2, 'Normal', 'Normal Priority', 2, 1), - (3, 'Low', 'Low Priority', 3, 1) -) -AS s -([Id], [Name], [Description], [DisplayOrder], [IsActive]) -ON (t.[Id] = s.[Id]) -WHEN NOT MATCHED BY TARGET THEN - INSERT ([Id], [Name], [Description], [DisplayOrder], [IsActive]) - VALUES (s.[Id], s.[Name], s.[Description], s.[DisplayOrder], s.[IsActive]) -WHEN MATCHED THEN - UPDATE SET t.[Name] = s.[Name], t.[Description] = s.[Description], t.[DisplayOrder] = s.[DisplayOrder], t.[IsActive] = s.[IsActive] -OUTPUT $action as [Action]; - --- Table [dbo].[Status] data - -MERGE INTO [dbo].[Status] AS t -USING -( - VALUES - (1, 'Not Started', 'Not Starated', 1, 1), - (2, 'In Progress', 'In Progress', 2, 1), - (3, 'Completed', 'Completed', 3, 1), - (4, 'Blocked', 'Blocked', 4, 1), - (5, 'Deferred', 'Deferred', 5, 1), - (6, 'Done', 'Done', 6, 1) -) -AS s -([Id], [Name], [Description], [DisplayOrder], [IsActive]) -ON (t.[Id] = s.[Id]) -WHEN NOT MATCHED BY TARGET THEN - INSERT ([Id], [Name], [Description], [DisplayOrder], [IsActive]) - VALUES (s.[Id], s.[Name], s.[Description], s.[DisplayOrder], s.[IsActive]) -WHEN MATCHED THEN - UPDATE SET t.[Name] = s.[Name], t.[Description] = s.[Description], t.[DisplayOrder] = s.[DisplayOrder], t.[IsActive] = s.[IsActive] -OUTPUT $action as [Action]; - --- Table [dbo].[User] data - -MERGE INTO [dbo].[User] AS t -USING -( - VALUES - ('83507c95-0744-e811-bd87-f8633fc30ac7', 'william.adama@battlestar.com', 1, 'William Adama'), - ('490312a6-0744-e811-bd87-f8633fc30ac7', 'laura.roslin@battlestar.com', 1, 'Laura Roslin'), - ('38da04bb-0744-e811-bd87-f8633fc30ac7', 'kara.thrace@battlestar.com', 1, 'Kara Thrace'), - ('589d67c6-0744-e811-bd87-f8633fc30ac7', 'lee.adama@battlestar.com', 1, 'Lee Adama'), - ('118b84d4-0744-e811-bd87-f8633fc30ac7', 'gaius.baltar@battlestar.com', 1, 'Gaius Baltar'), - ('fa7515df-0744-e811-bd87-f8633fc30ac7', 'saul.tigh@battlestar.com', 1, 'Saul Tigh') -) -AS s -([Id], [EmailAddress], [IsEmailAddressConfirmed], [DisplayName]) -ON (t.[Id] = s.[Id]) -WHEN NOT MATCHED BY TARGET THEN - INSERT ([Id], [EmailAddress], [IsEmailAddressConfirmed], [DisplayName]) - VALUES (s.[Id], s.[EmailAddress], s.[IsEmailAddressConfirmed], s.[DisplayName]) -WHEN MATCHED THEN - UPDATE SET t.[EmailAddress] = s.[EmailAddress], t.[IsEmailAddressConfirmed] = s.[IsEmailAddressConfirmed], t.[DisplayName] = s.[DisplayName] -OUTPUT $action as [Action]; - --- Table [dbo].[Role] data - -MERGE INTO [dbo].[Role] AS t -USING -( - VALUES - ('b2d78522-0944-e811-bd87-f8633fc30ac7', 'Administrator', 'Administrator'), - ('b3d78522-0944-e811-bd87-f8633fc30ac7', 'Manager', 'Manager'), - ('acbffa29-0944-e811-bd87-f8633fc30ac7', 'Member', 'Member') -) -AS s -([Id], [Name], [Description]) -ON (t.[Id] = s.[Id]) -WHEN NOT MATCHED BY TARGET THEN - INSERT ([Id], [Name], [Description]) - VALUES (s.[Id], s.[Name], s.[Description]) -WHEN MATCHED THEN - UPDATE SET t.[Name] = s.[Name], t.[Description] = s.[Description] -OUTPUT $action as [Action]; - --- Table [dbo].[CitiesSpatial] data - -INSERT INTO [dbo].[CitiesSpatial] VALUES -('Sydney', 'POINT(151.2 -33.8)', 'POINT(151.2 -33.8)'), -('Athens', 'POINT(23.7 38)', 'POINT(23.7 38)'), -('Beijing', 'POINT(116.4 39.9)', 'POINT(116.4 39.9)'), -('London', 'POINT(-0.15 51.5)', 'POINT(-0.15 51.5)'); \ No newline at end of file diff --git a/tests/TestDatabase/Script003.Tracker.User.sql b/tests/TestDatabase/Script003.Tracker.User.sql deleted file mode 100644 index 1266f16..0000000 --- a/tests/TestDatabase/Script003.Tracker.User.sql +++ /dev/null @@ -1,17 +0,0 @@ -IF NOT EXISTS - (SELECT name - FROM master.sys.sql_logins - WHERE name = 'testuser') -BEGIN - CREATE LOGIN [testuser] WITH PASSWORD = N'rglna{adQP123456'; -END --- check our db -IF NOT EXISTS - (SELECT name - FROM sys.database_principals - WHERE name = 'testuser') -BEGIN - CREATE USER [testuser] FOR LOGIN [testuser] WITH DEFAULT_SCHEMA = dbo -END -exec sp_addrolemember db_datareader, 'testuser' -exec sp_addrolemember db_datawriter, 'testuser' diff --git a/tests/TestDatabase/Tracker.sql b/tests/TestDatabase/Tracker.sql deleted file mode 100644 index 84f9543..0000000 --- a/tests/TestDatabase/Tracker.sql +++ /dev/null @@ -1,40 +0,0 @@ -SET NOCOUNT ON -GO - -set nocount on -set dateformat mdy - -USE master - -declare @dttm varchar(55) -select @dttm=convert(varchar,getdate(),113) -raiserror('Beginning InstPubs.SQL at %s ....',1,1,@dttm) with nowait - -GO - -if exists (select * from sysdatabases where name='pubs') -begin - raiserror('Dropping existing pubs database ....',0,1) - DROP database pubs -end -GO - -CHECKPOINT -go - -raiserror('Creating pubs database....',0,1) -go -/* - Use default size with autogrow -*/ - -CREATE DATABASE pubs -GO - -CHECKPOINT - -GO - -USE pubs - -GO \ No newline at end of file diff --git a/tests/TestDatabase/build.sh b/tests/TestDatabase/build.sh deleted file mode 100644 index 751e9a4..0000000 --- a/tests/TestDatabase/build.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e - -if [ ! -f adventureworks.bak ]; then - echo "Downloading AdventureWorks OLTP backup file from Microsoft..."; - wget https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2022.bak -O adventureworks.bak -q; - echo "Download complete."; -else - echo "AdventureWorks OLTP backup file already downloaded. Skipping."; -fi -if [ ! -f adventureworks-dw.bak ]; then - echo "Downloading AdventureWorks data warehouse backup file from Microsoft..."; - wget https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2022.bak -O adventureworks-dw.bak -q; - echo "Download complete."; -else - echo "AdventureWorks data warehouse backup file already downloaded. Skipping."; -fi -if [ ! -f adventureworks-light.bak ]; then - echo "Downloading AdventureWorks light backup file from Microsoft..."; - wget https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2022.bak -O adventureworks-light.bak -q; - echo "Download complete."; -else - echo "AdventureWorks light backup file already downloaded. Skipping."; -fi -echo "Building OLTP docker image."; -docker build --platform linux/386,linux/amd64 . -t chriseaton/adventureworks:latest --build-arg BAK_FILE=./adventureworks.bak --build-arg SQL_FILE=./install.sql; -docker tag chriseaton/adventureworks:latest chriseaton/adventureworks:oltp; -docker tag chriseaton/adventureworks:latest chriseaton/adventureworks:oltp-2022; -echo "Building data warehouse docker image."; -docker build --platform linux/386,linux/amd64 . -t chriseaton/adventureworks:datawarehouse --build-arg BAK_FILE=./adventureworks-dw.bak --build-arg SQL_FILE=./install-dw.sql; -docker tag chriseaton/adventureworks:datawarehouse chriseaton/adventureworks:datawarehouse-2022; -echo "Building light docker image."; -docker build --platform linux/386,linux/amd64 . -t chriseaton/adventureworks:light --build-arg BAK_FILE=./adventureworks-light.bak --build-arg SQL_FILE=./install.sql; -docker tag chriseaton/adventureworks:light chriseaton/adventureworks:light-2022; \ No newline at end of file diff --git a/tests/TestDatabase/install-dw.sql b/tests/TestDatabase/install-dw.sql deleted file mode 100644 index ac6ab56..0000000 --- a/tests/TestDatabase/install-dw.sql +++ /dev/null @@ -1,8 +0,0 @@ -USE [master] -GO - -RESTORE DATABASE [AdventureWorks] - FROM DISK = '/adventureworks.bak' - WITH MOVE 'AdventureWorksDW2022' TO '/var/opt/mssql/data/AdventureWorks.mdf', - MOVE 'AdventureWorksDW2022_log' TO '/var/opt/mssql/data/AdventureWorks_log.ldf' -GO \ No newline at end of file diff --git a/tests/TestDatabase/install.sh b/tests/TestDatabase/install.sh deleted file mode 100644 index 8206cbe..0000000 --- a/tests/TestDatabase/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo "Running installation script..." - -#wait for the SQL Server to come up -sleep 30s - -#run the setup script to create the DB and the schema in the DB -/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "Test_123_Test" -i Tracker.sql -echo -echo "Done installing database." -echo "Server is ready." -sleep infinity \ No newline at end of file diff --git a/tests/TestDatabase/install.sql b/tests/TestDatabase/install.sql deleted file mode 100644 index 19d5414..0000000 --- a/tests/TestDatabase/install.sql +++ /dev/null @@ -1,8 +0,0 @@ -USE [master] -GO - -RESTORE DATABASE [AdventureWorks] - FROM DISK = '/adventureworks.bak' - WITH MOVE 'AdventureWorks2022' TO '/var/opt/mssql/data/AdventureWorks.mdf', - MOVE 'AdventureWorks2022_log' TO '/var/opt/mssql/data/AdventureWorks_log.ldf' -GO \ No newline at end of file diff --git a/tests/TestDatabase/startup.sh b/tests/TestDatabase/startup.sh deleted file mode 100644 index 3dd61d3..0000000 --- a/tests/TestDatabase/startup.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "Starting server..." -/opt/mssql/bin/sqlservr & ./install.sh \ No newline at end of file diff --git a/yaml-entity.csx b/yaml-entity.csx deleted file mode 100644 index 5afe8c2..0000000 --- a/yaml-entity.csx +++ /dev/null @@ -1,65 +0,0 @@ -public string WriteCode() -{ - CodeBuilder.Clear(); - foreach (var entity in EntityContext.Entities) - { - CodeBuilder.Append("EntityClass: ").Append(entity.EntityClass.ToSafeName()).AppendLine(); - - CodeBuilder.Append("ContextProperty: ").Append(entity.ContextProperty.ToSafeName()).AppendLine(); - - CodeBuilder.Append("TableSchema: '").Append(entity.TableSchema.ToSafeName()).AppendLine("'"); - CodeBuilder.Append("TableName: '").Append(entity.TableName.ToSafeName()).AppendLine("'"); - - - CodeBuilder.Append("IsView: ").Append(entity.IsView.ToString()).AppendLine(); - - CodeBuilder.Append("Properties:").AppendLine(); - using (CodeBuilder.Indent()) - GenerateProperties(entity); - } - - return CodeBuilder.ToString(); -} - -private void GenerateProperties(Entity entity) -{ - foreach (var property in entity.Properties) - { - CodeBuilder.Append("- PropertyName: ").Append(property.PropertyName.ToSafeName()).AppendLine(); - CodeBuilder.Append(" ColumnName: '").Append(property.ColumnName.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" StoreType: ").Append(property.StoreType.ToSafeName()).AppendLine(); - CodeBuilder.Append(" NativeType: '").Append(property.NativeType.ToSafeName()).AppendLine("'"); - CodeBuilder.Append(" DataType: ").Append(property.DataType.ToString()).AppendLine(); - CodeBuilder.Append(" SystemType: ").Append(property.SystemType.Name).AppendLine(); - - if (property.Size != null) - CodeBuilder.Append(" Size: ").Append(property.Size.ToString()).AppendLine(); - - if (property.Default != null) - CodeBuilder.Append(" Default: '").Append(property.Default.ToSafeName()).AppendLine("'"); - - if (property.ValueGenerated != null) - CodeBuilder.Append(" ValueGenerated: ").Append(property.ValueGenerated.ToString()).AppendLine(); - - if (property.IsNullable != null) - CodeBuilder.Append(" IsNullable: ").Append(property.IsNullable.ToString()).AppendLine(); - - if (property.IsPrimaryKey != null) - CodeBuilder.Append(" IsPrimaryKey: ").Append(property.IsPrimaryKey.ToString()).AppendLine(); - - if (property.IsForeignKey != null) - CodeBuilder.Append(" IsForeignKey: ").Append(property.IsForeignKey.ToString()).AppendLine(); - - if (property.IsReadOnly != null) - CodeBuilder.Append(" IsReadOnly: ").Append(property.IsReadOnly.ToString()).AppendLine(); - - if (property.IsRowVersion != null) - CodeBuilder.Append(" IsRowVersion: ").Append(property.IsRowVersion.ToString()).AppendLine(); - - if (property.IsUnique != null) - CodeBuilder.Append(" IsUnique: ").Append(property.IsUnique.ToString()).AppendLine(); - } -} - -// run script -WriteCode()