diff --git a/.gitignore b/.gitignore index 5340c6e7..98202a43 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ nupkg **/.idea/**/tasks.xml **/.idea/shelf/* **/.idea/dictionaries +.idea # Sensitive or high-churn files **/.idea/**/dataSources/ diff --git a/src/.devcontainer/postgresql/install.sql b/src/.devcontainer/postgresql/install.sql index 84a26deb..f553bf14 100644 --- a/src/.devcontainer/postgresql/install.sql +++ b/src/.devcontainer/postgresql/install.sql @@ -3293,6 +3293,13 @@ CREATE SCHEMA sa CREATE VIEW s AS SELECT businessentityid AS id, * FROM sales.store ; +CREATE SCHEMA ProviderDbTypeTest + CREATE TABLE Test ( + ID SERIAL, + JSON_FIELD JSON NOT NULL, + JSONB_FIELD JSONB NOT NULL + ); + \pset tuples_only off diff --git a/src/SqlHydra/Domain.fs b/src/SqlHydra.Domain/Domain.fs similarity index 57% rename from src/SqlHydra/Domain.fs rename to src/SqlHydra.Domain/Domain.fs index 3b228c19..1300ae73 100644 --- a/src/SqlHydra/Domain.fs +++ b/src/SqlHydra.Domain/Domain.fs @@ -13,6 +13,7 @@ type TypeMapping = { ClrType: string DbType: DbType + ProviderDbType: string option ColumnTypeAlias: string ReaderMethod: string } @@ -74,33 +75,3 @@ type Config = Filters: Filters Readers: ReadersConfig option } - -open GlobExpressions - -let applyFilters (filters: Filters) (tables: Table list) = - match filters with - | { Includes = []; Excludes = [] } -> - tables - | _ -> - let getPath tbl = $"{tbl.Schema}/{tbl.Name}" - let tablesByPath = tables |> List.map (fun t -> getPath t, t) |> Map.ofList - let paths = tablesByPath |> Map.toList |> List.map fst - - let includePatterns = filters.Includes |> List.map Glob - let excludePatterns = filters.Excludes |> List.map Glob - - let includedPaths = - includePatterns - |> List.collect (fun pattern -> paths |> List.filter pattern.IsMatch) - |> List.distinct - |> Set.ofList - - let excludedPaths = - excludePatterns - |> List.collect (fun pattern -> paths |> List.filter pattern.IsMatch) - |> List.distinct - |> Set.ofList - - let filteredPaths = includedPaths - excludedPaths - let filteredTables = filteredPaths |> Seq.map (fun path -> tablesByPath.[path]) |> Seq.toList - filteredTables diff --git a/src/SqlHydra.Domain/ProviderDbTypeAttribute.fs b/src/SqlHydra.Domain/ProviderDbTypeAttribute.fs new file mode 100644 index 00000000..1a61f82b --- /dev/null +++ b/src/SqlHydra.Domain/ProviderDbTypeAttribute.fs @@ -0,0 +1,10 @@ +namespace SqlHydra + +open System + +[] +type ProviderDbTypeAttribute(providerDbTypeName: string) = + inherit Attribute() + + member this.ProviderDbTypeName = providerDbTypeName diff --git a/src/SqlHydra.Domain/SqlHydra.Domain.fsproj b/src/SqlHydra.Domain/SqlHydra.Domain.fsproj new file mode 100644 index 00000000..0269efa4 --- /dev/null +++ b/src/SqlHydra.Domain/SqlHydra.Domain.fsproj @@ -0,0 +1,14 @@ + + + + netstandard2.0 + true + 3390;$(WarnOn) + + + + + + + + diff --git a/src/SqlHydra.Npgsql/NpgsqlDataTypes.fs b/src/SqlHydra.Npgsql/NpgsqlDataTypes.fs index 6d822d4c..d282ab6a 100644 --- a/src/SqlHydra.Npgsql/NpgsqlDataTypes.fs +++ b/src/SqlHydra.Npgsql/NpgsqlDataTypes.fs @@ -1,6 +1,7 @@ module SqlHydra.Npgsql.NpgsqlDataTypes open System.Data +open NpgsqlTypes open SqlHydra.Domain let private r : Npgsql.NpgsqlDataReader = null @@ -8,48 +9,49 @@ let private r : Npgsql.NpgsqlDataReader = null /// A list of supported column type mappings let supportedTypeMappings = [ - "boolean", "bool", DbType.Boolean, nameof r.GetBoolean - "smallint", "int16", DbType.Int16, nameof r.GetInt16 - "integer", "int", DbType.Int32, nameof r.GetInt32 - "bigint", "int64", DbType.Int64, nameof r.GetInt64 - "real", "double", DbType.Double, nameof r.GetDouble - "double precision", "double", DbType.Double, nameof r.GetDouble - "numeric", "decimal", DbType.Decimal, nameof r.GetDecimal - "money", "decimal", DbType.Decimal, nameof r.GetDecimal - "text", "string", DbType.String, nameof r.GetString - "character varying", "string", DbType.String, nameof r.GetString - "character", "string", DbType.String, nameof r.GetString - "citext", "string", DbType.String, nameof r.GetString - "json", "string", DbType.String, nameof r.GetString - "jsonb", "string", DbType.String, nameof r.GetString - "xml", "string", DbType.String, nameof r.GetString + "boolean", "bool", DbType.Boolean, None, nameof r.GetBoolean + "smallint", "int16", DbType.Int16, None, nameof r.GetInt16 + "integer", "int", DbType.Int32, None, nameof r.GetInt32 + "bigint", "int64", DbType.Int64, None, nameof r.GetInt64 + "real", "double", DbType.Double, None, nameof r.GetDouble + "double precision", "double", DbType.Double, None, nameof r.GetDouble + "numeric", "decimal", DbType.Decimal, None, nameof r.GetDecimal + "money", "decimal", DbType.Decimal, None, nameof r.GetDecimal + "text", "string", DbType.String, None, nameof r.GetString + "character varying", "string", DbType.String, None, nameof r.GetString + "character", "string", DbType.String, None, nameof r.GetString + "citext", "string", DbType.String, None, nameof r.GetString + "json", "string", DbType.String, Some (nameof NpgsqlDbType.Json), nameof r.GetString + "jsonb", "string", DbType.String, Some (nameof NpgsqlDbType.Jsonb), nameof r.GetString + "xml", "string", DbType.String, None, nameof r.GetString // skipped unsupported types - "bit(1)", "bool", DbType.Boolean, nameof r.GetBoolean + "bit(1)", "bool", DbType.Boolean, None, nameof r.GetBoolean // skipped unsupported types - "uuid", "System.Guid", DbType.Guid, nameof r.GetGuid + "uuid", "System.Guid", DbType.Guid, None, nameof r.GetGuid // skipped unsupported types - "date", "System.DateTime", DbType.DateTime, nameof r.GetDateTime - "interval", "System.TimeSpan", DbType.Time, nameof r.GetTimeSpan - "timestamp without time zone", "System.DateTime", DbType.DateTime, nameof r.GetDateTime - "timestamp with time zone", "System.DateTime", DbType.DateTime, nameof r.GetDateTime - "time without time zone", "System.TimeSpan", DbType.Time, nameof r.GetTimeSpan - "time with time zone", "System.DateTime", DbType.DateTime, nameof r.GetDateTime - "bytea", "byte[]", DbType.Binary, nameof r.GetValue + "date", "System.DateTime", DbType.DateTime, None, nameof r.GetDateTime + "interval", "System.TimeSpan", DbType.Time, None, nameof r.GetTimeSpan + "timestamp without time zone", "System.DateTime", DbType.DateTime, None, nameof r.GetDateTime + "timestamp with time zone", "System.DateTime", DbType.DateTime, None, nameof r.GetDateTime + "time without time zone", "System.TimeSpan", DbType.Time, None, nameof r.GetTimeSpan + "time with time zone", "System.DateTime", DbType.DateTime, None, nameof r.GetDateTime + "bytea", "byte[]", DbType.Binary, None, nameof r.GetValue // skipped unsupported types - "name", "string", DbType.String, nameof r.GetString - "(internal) char", "char", DbType.String, nameof r.GetChar + "name", "string", DbType.String, None, nameof r.GetString + "(internal) char", "char", DbType.String, None, nameof r.GetChar // skipped unsupported types ] let typeMappingsByName = supportedTypeMappings - |> List.map (fun (columnTypeAlias, clrType, dbType, readerMethod) -> + |> List.map (fun (columnTypeAlias, clrType, dbType, providerDbType, readerMethod) -> columnTypeAlias, { TypeMapping.ColumnTypeAlias = columnTypeAlias TypeMapping.ClrType = clrType TypeMapping.DbType = dbType TypeMapping.ReaderMethod = readerMethod + TypeMapping.ProviderDbType = providerDbType } ) |> Map.ofList @@ -59,7 +61,7 @@ let tryFindTypeMapping (providerTypeName: string) = let primitiveTypeReaders = supportedTypeMappings - |> List.map(fun (_, clrType, _, readerMethod) -> + |> List.map(fun (_, clrType, _, _, readerMethod) -> { PrimitiveTypeReader.ClrType = clrType; PrimitiveTypeReader.ReaderMethod = readerMethod } ) |> List.distinctBy (fun ptr -> ptr.ClrType) diff --git a/src/SqlHydra.Npgsql/NpgsqlSchemaProvider.fs b/src/SqlHydra.Npgsql/NpgsqlSchemaProvider.fs index 39392691..eb2ed52b 100644 --- a/src/SqlHydra.Npgsql/NpgsqlSchemaProvider.fs +++ b/src/SqlHydra.Npgsql/NpgsqlSchemaProvider.fs @@ -1,7 +1,6 @@ module SqlHydra.Npgsql.NpgsqlSchemaProvider open System.Data -open Npgsql open SqlHydra.Domain let getSchema (cfg: Config) : Schema = @@ -52,12 +51,14 @@ let getSchema (cfg: Config) : Schema = TableName = col.["TABLE_NAME"] :?> string ColumnName = col.["COLUMN_NAME"] :?> string ProviderTypeName = col.["DATA_TYPE"] :?> string + OrdinalPosition = col.["ORDINAL_POSITION"] :?> int IsNullable = match col.["IS_NULLABLE"] :?> string with | "YES" -> true | _ -> false |} ) + |> Seq.sortBy (fun column -> column.OrdinalPosition) let tables = sTables.Rows diff --git a/src/SqlHydra.Query/Kata.fs b/src/SqlHydra.Query/Kata.fs index 59aced4f..b2aab5bb 100644 --- a/src/SqlHydra.Query/Kata.fs +++ b/src/SqlHydra.Query/Kata.fs @@ -1,5 +1,6 @@ namespace SqlHydra.Query +open System.Reflection open SqlKata open System.Collections.Generic open System @@ -25,6 +26,12 @@ module FQ = | Some schema -> $"{schema}.{tbl.Name}" | None -> tbl.Name +type QueryParameter = + { + Value: obj + ProviderDbType: string option + } + type InsertQuerySpec<'T, 'Identity> = { Table: string @@ -68,7 +75,7 @@ type QuerySource<'T, 'Query>(query, tableMappings) = module private KataUtils = /// Boxes values (and option values) - let boxValueOrOption (value: obj) = + let private boxValueOrOption (value: obj) = if isNull value then box System.DBNull.Value else @@ -80,6 +87,21 @@ module private KataUtils = | null -> box System.DBNull.Value | o -> o + let private getProviderDbTypeName (p: PropertyInfo) = + let attrs = p.GetCustomAttributes(true) + (attrs + |> Seq.choose (function + | :? SqlHydra.ProviderDbTypeAttribute as attr -> Some attr.ProviderDbTypeName + | _ -> None)) + |> Seq.tryHead + + let getQueryParameterForValue (p: PropertyInfo) (value: obj) = + { Value = value |> boxValueOrOption; ProviderDbType = getProviderDbTypeName p } + + let getQueryParameterForEntity (entity: 'T) (p: PropertyInfo) = + p.GetValue(entity) + |> getQueryParameterForValue p + let fromUpdate (spec: UpdateQuerySpec<'T>) = let kvps = match spec.Entity, spec.SetValues with @@ -87,13 +109,13 @@ module private KataUtils = match spec.Fields with | [] -> FSharp.Reflection.FSharpType.GetRecordFields(typeof<'T>) - |> Array.map (fun p -> p.Name, p.GetValue(entity)) + |> Array.map (fun p -> p.Name, getQueryParameterForEntity entity p :> obj) | fields -> let included = fields |> Set.ofList FSharp.Reflection.FSharpType.GetRecordFields(typeof<'T>) |> Array.filter (fun p -> included.Contains(p.Name)) - |> Array.map (fun p -> p.Name, p.GetValue(entity)) + |> Array.map (fun p -> p.Name, getQueryParameterForEntity entity p :> obj) | Some _, _ -> failwith "Cannot have both `entity` and `set` operations in an `update` expression." | None, [] -> failwith "Either an `entity` or `set` operations must be present in an `update` expression." @@ -101,7 +123,7 @@ module private KataUtils = let preparedKvps = kvps - |> Seq.map (fun (key,value) -> key, boxValueOrOption value) + |> Seq.map (fun (key,value) -> key, value) |> dict |> Seq.map id @@ -129,7 +151,7 @@ module private KataUtils = | [ entity ] -> let keyValuePairs = includedProperties - |> Array.map (fun p -> KeyValuePair(p.Name, p.GetValue(entity) |> boxValueOrOption)) + |> Array.map (fun p -> KeyValuePair(p.Name, getQueryParameterForEntity entity p :> obj)) |> Array.toList Query(spec.Table).AsInsert(keyValuePairs, returnId = spec.IdentityField.IsSome) @@ -141,7 +163,7 @@ module private KataUtils = entities |> List.map (fun entity -> includedProperties - |> Array.map (fun p -> p.GetValue(entity) |> boxValueOrOption) + |> Array.map (fun p -> getQueryParameterForEntity entity p :> obj) |> Array.toSeq ) Query(spec.Table).AsInsert(columns, rowsValues) diff --git a/src/SqlHydra.Query/KataBuilders.fs b/src/SqlHydra.Query/KataBuilders.fs index e2a6edf3..7e0fcea8 100644 --- a/src/SqlHydra.Query/KataBuilders.fs +++ b/src/SqlHydra.Query/KataBuilders.fs @@ -370,8 +370,10 @@ type UpdateExpressionBuilder<'T>() = member this.Set (state: QuerySource<'T>, [] propertySelector: Expression>, value: 'Prop) = let query = state |> getQueryOrDefault let prop = LinqExpressionVisitors.visitPropertySelector<'T, 'Prop> propertySelector :?> Reflection.PropertyInfo + + let value = KataUtils.getQueryParameterForValue prop value :> obj QuerySource<'T, UpdateQuerySpec<'T>>( - { query with SetValues = query.SetValues @ [ prop.Name, box value ] } + { query with SetValues = query.SetValues @ [ prop.Name, value ] } , state.TableMappings) /// Includes a column in the insert query. diff --git a/src/SqlHydra.Query/QueryContext.fs b/src/SqlHydra.Query/QueryContext.fs index 0f5ff7af..eb6e5639 100644 --- a/src/SqlHydra.Query/QueryContext.fs +++ b/src/SqlHydra.Query/QueryContext.fs @@ -5,7 +5,21 @@ open SqlKata /// Contains methods that compile and read a query. type QueryContext(conn: DbConnection, compiler: SqlKata.Compilers.Compiler) = - + let setProviderDbType (param: DbParameter) (propertyName: string) (providerDbType: string) = + let property = param.GetType().GetProperty(propertyName) + let dbTypeSetter = property.GetSetMethod() + + let value = System.Enum.Parse(property.PropertyType, providerDbType) + dbTypeSetter.Invoke(param, [|value|]) |> ignore + + let setParameterDbType (param: DbParameter) (qp: QueryParameter) = + match qp.ProviderDbType, compiler with + | Some type', :? SqlKata.Compilers.PostgresCompiler -> + setProviderDbType param "NpgsqlDbType" type' + | Some type', :? SqlKata.Compilers.SqlServerCompiler -> + setProviderDbType param "SqlDbType" type' + | _ -> () + interface System.IDisposable with member this.Dispose() = conn.Dispose() @@ -44,7 +58,13 @@ type QueryContext(conn: DbConnection, compiler: SqlKata.Compilers.Compiler) = for kvp in compiledQuery.NamedBindings do let p = cmd.CreateParameter() p.ParameterName <- kvp.Key - p.Value <- kvp.Value + + match kvp.Value with + | :? QueryParameter as qp -> + do setParameterDbType p qp + p.Value <- qp.Value + | _ -> + p.Value <- kvp.Value cmd.Parameters.Add(p) |> ignore cmd diff --git a/src/SqlHydra.Query/SqlHydra.Query.fsproj b/src/SqlHydra.Query/SqlHydra.Query.fsproj index 4ab06932..9f62a80d 100644 --- a/src/SqlHydra.Query/SqlHydra.Query.fsproj +++ b/src/SqlHydra.Query/SqlHydra.Query.fsproj @@ -9,6 +9,7 @@ Jordan Marr F# fsharp data database orm sql LICENSE + $(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage SqlHydra.Query: Added support for multiple inserts via the `entities` operation. @@ -32,4 +33,8 @@ + + + + diff --git a/src/SqlHydra.SqlServer/SqlHydra.SqlServer.fsproj b/src/SqlHydra.SqlServer/SqlHydra.SqlServer.fsproj index 35f9ceea..646bd909 100644 --- a/src/SqlHydra.SqlServer/SqlHydra.SqlServer.fsproj +++ b/src/SqlHydra.SqlServer/SqlHydra.SqlServer.fsproj @@ -39,6 +39,7 @@ + true SqlHydra.dll diff --git a/src/SqlHydra.SqlServer/SqlServerDataTypes.fs b/src/SqlHydra.SqlServer/SqlServerDataTypes.fs index 69e22e32..db27bf0d 100644 --- a/src/SqlHydra.SqlServer/SqlServerDataTypes.fs +++ b/src/SqlHydra.SqlServer/SqlServerDataTypes.fs @@ -54,6 +54,7 @@ let typeMappingsByName = TypeMapping.ClrType = clrType TypeMapping.DbType = dbType TypeMapping.ReaderMethod = readerMethod + TypeMapping.ProviderDbType = None } ) |> Map.ofList diff --git a/src/SqlHydra.SqlServer/SqlServerSchemaProvider.fs b/src/SqlHydra.SqlServer/SqlServerSchemaProvider.fs index a8f69555..d573fc29 100644 --- a/src/SqlHydra.SqlServer/SqlServerSchemaProvider.fs +++ b/src/SqlHydra.SqlServer/SqlServerSchemaProvider.fs @@ -73,7 +73,7 @@ let getSchema (cfg: Config) : Schema = |> Seq.choose (fun col -> SqlServerDataTypes.tryFindTypeMapping(col.ProviderTypeName) |> Option.map (fun typeMapping -> - { + { Column.Name = col.ColumnName Column.IsNullable = col.IsNullable Column.TypeMapping = typeMapping diff --git a/src/SqlHydra.Sqlite/SqlHydra.Sqlite.fsproj b/src/SqlHydra.Sqlite/SqlHydra.Sqlite.fsproj index 616f73a3..733cbc35 100644 --- a/src/SqlHydra.Sqlite/SqlHydra.Sqlite.fsproj +++ b/src/SqlHydra.Sqlite/SqlHydra.Sqlite.fsproj @@ -38,6 +38,7 @@ + true SqlHydra.dll diff --git a/src/SqlHydra.Sqlite/SqliteDataTypes.fs b/src/SqlHydra.Sqlite/SqliteDataTypes.fs index edd2c044..44a59891 100644 --- a/src/SqlHydra.Sqlite/SqliteDataTypes.fs +++ b/src/SqlHydra.Sqlite/SqliteDataTypes.fs @@ -66,6 +66,7 @@ let typeMappingsByName = TypeMapping.ClrType = clrType TypeMapping.DbType = dbType TypeMapping.ReaderMethod = readerMethod + TypeMapping.ProviderDbType = None } ) |> Map.ofList diff --git a/src/SqlHydra.sln b/src/SqlHydra.sln index e73863cb..fce84e39 100644 --- a/src/SqlHydra.sln +++ b/src/SqlHydra.sln @@ -23,6 +23,8 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SqlHydra.Npgsql", "SqlHydra EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Build", "Build\Build.fsproj", "{1D3ACD32-25B4-40BA-BFE8-6292F3F1A6B4}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SqlHydra.Domain", "SqlHydra.Domain\SqlHydra.Domain.fsproj", "{958CEE47-CC2A-4CA2-BFE3-53653CB39604}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -180,6 +182,24 @@ Global {1D3ACD32-25B4-40BA-BFE8-6292F3F1A6B4}.Release|x64.Build.0 = Release|Any CPU {1D3ACD32-25B4-40BA-BFE8-6292F3F1A6B4}.Release|x86.ActiveCfg = Release|Any CPU {1D3ACD32-25B4-40BA-BFE8-6292F3F1A6B4}.Release|x86.Build.0 = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|Any CPU.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|x64.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|x64.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|x86.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Debug|x86.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|Any CPU.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|Any CPU.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|x64.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|x64.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|x86.ActiveCfg = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.DebugLocal|x86.Build.0 = Debug|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|Any CPU.ActiveCfg = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|Any CPU.Build.0 = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|x64.ActiveCfg = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|x64.Build.0 = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|x86.ActiveCfg = Release|Any CPU + {958CEE47-CC2A-4CA2-BFE3-53653CB39604}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/SqlHydra/Filter.fs b/src/SqlHydra/Filter.fs new file mode 100644 index 00000000..de2152e1 --- /dev/null +++ b/src/SqlHydra/Filter.fs @@ -0,0 +1,32 @@ +module SqlHydra.Filter + +open GlobExpressions +open SqlHydra.Domain + +let applyFilters (filters: Filters) (tables: Table list) = + match filters with + | { Includes = []; Excludes = [] } -> + tables + | _ -> + let getPath tbl = $"{tbl.Schema}/{tbl.Name}" + let tablesByPath = tables |> List.map (fun t -> getPath t, t) |> Map.ofList + let paths = tablesByPath |> Map.toList |> List.map fst + + let includePatterns = filters.Includes |> List.map Glob + let excludePatterns = filters.Excludes |> List.map Glob + + let includedPaths = + includePatterns + |> List.collect (fun pattern -> paths |> List.filter pattern.IsMatch) + |> List.distinct + |> Set.ofList + + let excludedPaths = + excludePatterns + |> List.collect (fun pattern -> paths |> List.filter pattern.IsMatch) + |> List.distinct + |> Set.ofList + + let filteredPaths = includedPaths - excludedPaths + let filteredTables = filteredPaths |> Seq.map (fun path -> tablesByPath.[path]) |> Seq.toList + filteredTables diff --git a/src/SqlHydra/SchemaGenerator.fs b/src/SqlHydra/SchemaGenerator.fs index b4b5c32f..0b8a5e76 100644 --- a/src/SqlHydra/SchemaGenerator.fs +++ b/src/SqlHydra/SchemaGenerator.fs @@ -1,10 +1,12 @@ module SqlHydra.SchemaGenerator open FSharp.Compiler.SyntaxTree open FSharp.Compiler +open FSharp.Compiler.XmlDoc open FsAst open Fantomas open Domain open System.Data +open SqlHydra.Filter let range0 = Range.range.Zero @@ -23,6 +25,21 @@ let cliMutableAttribute = let atts = [ SynAttributeList.Create(attr) ] SynModuleDecl.CreateAttributes(atts) +let createProviderDbTypeAttribute (mapping: TypeMapping) = + mapping.ProviderDbType + |> Option.map (fun type' -> + let attributeFullName = typeof.FullName + + let attr = + { TypeName = LongIdentWithDots.Create (attributeFullName.Split(".") |> List.ofArray) + ; ArgExpr = SynExpr.CreateParenedTuple [ SynExpr.CreateConst (SynConst.String(type', range0)) ] + ; Target = None + ; AppliesToGetterAndSetter = false + ; Range = range0 } : SynAttribute + + SynAttributes.Cons (SynAttributeList.Create attr, SynAttributes.Empty) + ) |> Option.defaultValue SynAttributes.Empty + /// Creates a record definition named after a table. let createTableRecord (tbl: Table) = let myRecordId = LongIdentWithDots.CreateString tbl.Name @@ -30,19 +47,32 @@ let createTableRecord (tbl: Table) = let recordDef = tbl.Columns - |> List.map (fun col -> + |> List.map (fun col -> let field = if col.TypeMapping.ClrType = "byte[]" then let b = SynType.Create("byte") SynType.Array(0, b, range0) else SynType.Create(col.TypeMapping.ClrType) - - if col.IsNullable then - let opt = SynType.Option(field) - SynFieldRcd.Create(Ident.Create(col.Name), opt) - else - SynFieldRcd.Create(Ident.Create(col.Name), field) + + let attributes = createProviderDbTypeAttribute col.TypeMapping + + let type' = + if col.IsNullable then + SynType.Option(field) + else + field + + { + Attributes = attributes + IsStatic = false + Id = Some (Ident.Create(col.Name)) + Type = type' + IsMutable = false + XmlDoc = PreXmlDoc.Empty + Access = None + Range = range0 + } ) |> SynTypeDefnSimpleReprRecordRcd.Create |> SynTypeDefnSimpleReprRcd.Record diff --git a/src/SqlHydra/SqlHydra.fsproj b/src/SqlHydra/SqlHydra.fsproj index 4fb9f107..786ac252 100644 --- a/src/SqlHydra/SqlHydra.fsproj +++ b/src/SqlHydra/SqlHydra.fsproj @@ -9,7 +9,7 @@ - + @@ -28,5 +28,9 @@ + + + + diff --git a/src/Tests/Npgsql/AdventureWorks.fs b/src/Tests/Npgsql/AdventureWorks.fs index 9ef363ee..72a37445 100644 --- a/src/Tests/Npgsql/AdventureWorks.fs +++ b/src/Tests/Npgsql/AdventureWorks.fs @@ -1,4 +1,4 @@ -// This code was generated by `SqlHydra.Npgsql` -- v0.510.0.0. +// This code was generated by `SqlHydra.Npgsql` -- v0.530.0.0. namespace Npgsql.AdventureWorks type Column(reader: System.Data.IDataReader, getOrdinal: string -> int, column) = @@ -31,147 +31,147 @@ type OptionalBinaryColumn<'T, 'Reader when 'Reader :> System.Data.IDataReader>(r module humanresources = [] type department = - { groupname: string - modifieddate: System.DateTime + { departmentid: int name: string - departmentid: int } + groupname: string + modifieddate: System.DateTime } type departmentReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.departmentid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "departmentid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.groupname = RequiredColumn(reader, getOrdinal, reader.GetString, "groupname") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.departmentid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "departmentid") member __.Read() = - { groupname = __.groupname.Read() - modifieddate = __.modifieddate.Read() + { departmentid = __.departmentid.Read() name = __.name.Read() - departmentid = __.departmentid.Read() } + groupname = __.groupname.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.departmentid.IsNull() then None else Some(__.Read()) [] type employee = - { hiredate: System.DateTime + { businessentityid: int + nationalidnumber: string + loginid: string + jobtitle: string birthdate: System.DateTime maritalstatus: string + gender: string + hiredate: System.DateTime + salariedflag: bool + vacationhours: int16 sickleavehours: int16 - nationalidnumber: string - modifieddate: System.DateTime currentflag: bool - loginid: string rowguid: System.Guid - organizationnode: Option - jobtitle: string - vacationhours: int16 - salariedflag: bool - businessentityid: int - gender: string } + modifieddate: System.DateTime + organizationnode: Option } type employeeReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.hiredate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "hiredate") + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.nationalidnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "nationalidnumber") + member __.loginid = RequiredColumn(reader, getOrdinal, reader.GetString, "loginid") + member __.jobtitle = RequiredColumn(reader, getOrdinal, reader.GetString, "jobtitle") member __.birthdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "birthdate") member __.maritalstatus = RequiredColumn(reader, getOrdinal, reader.GetString, "maritalstatus") + member __.gender = RequiredColumn(reader, getOrdinal, reader.GetString, "gender") + member __.hiredate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "hiredate") + member __.salariedflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "salariedflag") + member __.vacationhours = RequiredColumn(reader, getOrdinal, reader.GetInt16, "vacationhours") member __.sickleavehours = RequiredColumn(reader, getOrdinal, reader.GetInt16, "sickleavehours") - member __.nationalidnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "nationalidnumber") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.currentflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "currentflag") - member __.loginid = RequiredColumn(reader, getOrdinal, reader.GetString, "loginid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.organizationnode = OptionalColumn(reader, getOrdinal, reader.GetString, "organizationnode") - member __.jobtitle = RequiredColumn(reader, getOrdinal, reader.GetString, "jobtitle") - member __.vacationhours = RequiredColumn(reader, getOrdinal, reader.GetInt16, "vacationhours") - member __.salariedflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "salariedflag") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") - member __.gender = RequiredColumn(reader, getOrdinal, reader.GetString, "gender") member __.Read() = - { hiredate = __.hiredate.Read() + { businessentityid = __.businessentityid.Read() + nationalidnumber = __.nationalidnumber.Read() + loginid = __.loginid.Read() + jobtitle = __.jobtitle.Read() birthdate = __.birthdate.Read() maritalstatus = __.maritalstatus.Read() + gender = __.gender.Read() + hiredate = __.hiredate.Read() + salariedflag = __.salariedflag.Read() + vacationhours = __.vacationhours.Read() sickleavehours = __.sickleavehours.Read() - nationalidnumber = __.nationalidnumber.Read() - modifieddate = __.modifieddate.Read() currentflag = __.currentflag.Read() - loginid = __.loginid.Read() rowguid = __.rowguid.Read() - organizationnode = __.organizationnode.Read() - jobtitle = __.jobtitle.Read() - vacationhours = __.vacationhours.Read() - salariedflag = __.salariedflag.Read() - businessentityid = __.businessentityid.Read() - gender = __.gender.Read() } + modifieddate = __.modifieddate.Read() + organizationnode = __.organizationnode.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type employeedepartmenthistory = - { startdate: System.DateTime - shiftid: int16 + { businessentityid: int departmentid: int16 - modifieddate: System.DateTime - businessentityid: int - enddate: Option } + shiftid: int16 + startdate: System.DateTime + enddate: Option + modifieddate: System.DateTime } type employeedepartmenthistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") - member __.shiftid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "shiftid") - member __.departmentid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "departmentid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.departmentid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "departmentid") + member __.shiftid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "shiftid") + member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { startdate = __.startdate.Read() - shiftid = __.shiftid.Read() + { businessentityid = __.businessentityid.Read() departmentid = __.departmentid.Read() - modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() - enddate = __.enddate.Read() } + shiftid = __.shiftid.Read() + startdate = __.startdate.Read() + enddate = __.enddate.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.startdate.IsNull() then None else Some(__.Read()) + if __.businessentityid.IsNull() then None else Some(__.Read()) [] type employeepayhistory = - { modifieddate: System.DateTime - businessentityid: int + { businessentityid: int ratechangedate: System.DateTime rate: decimal - payfrequency: int16 } + payfrequency: int16 + modifieddate: System.DateTime } type employeepayhistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.ratechangedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "ratechangedate") member __.rate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "rate") member __.payfrequency = RequiredColumn(reader, getOrdinal, reader.GetInt16, "payfrequency") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() + { businessentityid = __.businessentityid.Read() ratechangedate = __.ratechangedate.Read() rate = __.rate.Read() - payfrequency = __.payfrequency.Read() } + payfrequency = __.payfrequency.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type jobcandidate = - { modifieddate: System.DateTime - resume: Option + { jobcandidateid: int businessentityid: Option - jobcandidateid: int } + resume: Option + modifieddate: System.DateTime } type jobcandidateReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.resume = OptionalColumn(reader, getOrdinal, reader.GetString, "resume") - member __.businessentityid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.jobcandidateid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "jobcandidateid") + member __.businessentityid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.resume = OptionalColumn(reader, getOrdinal, reader.GetString, "resume") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - resume = __.resume.Read() + { jobcandidateid = __.jobcandidateid.Read() businessentityid = __.businessentityid.Read() - jobcandidateid = __.jobcandidateid.Read() } + resume = __.resume.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.jobcandidateid.IsNull() then None else Some(__.Read()) @@ -179,23 +179,23 @@ module humanresources = [] type shift = { shiftid: int - modifieddate: System.DateTime - endtime: System.TimeSpan + name: string starttime: System.TimeSpan - name: string } + endtime: System.TimeSpan + modifieddate: System.DateTime } type shiftReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.shiftid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shiftid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.endtime = RequiredColumn(reader, getOrdinal, reader.GetTimeSpan, "endtime") - member __.starttime = RequiredColumn(reader, getOrdinal, reader.GetTimeSpan, "starttime") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.starttime = RequiredColumn(reader, getOrdinal, reader.GetTimeSpan, "starttime") + member __.endtime = RequiredColumn(reader, getOrdinal, reader.GetTimeSpan, "endtime") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { shiftid = __.shiftid.Read() - modifieddate = __.modifieddate.Read() - endtime = __.endtime.Read() + name = __.name.Read() starttime = __.starttime.Read() - name = __.name.Read() } + endtime = __.endtime.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.shiftid.IsNull() then None else Some(__.Read()) @@ -203,57 +203,57 @@ module humanresources = module person = [] type address = - { addressline1: string - city: string + { addressid: int + addressline1: string addressline2: Option - rowguid: System.Guid - spatiallocation: Option + city: string stateprovinceid: int - addressid: int - modifieddate: System.DateTime - postalcode: string } + postalcode: string + spatiallocation: Option + rowguid: System.Guid + modifieddate: System.DateTime } type addressReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.addressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addressid") member __.addressline1 = RequiredColumn(reader, getOrdinal, reader.GetString, "addressline1") - member __.city = RequiredColumn(reader, getOrdinal, reader.GetString, "city") member __.addressline2 = OptionalColumn(reader, getOrdinal, reader.GetString, "addressline2") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.spatiallocation = OptionalColumn(reader, getOrdinal, reader.GetString, "spatiallocation") + member __.city = RequiredColumn(reader, getOrdinal, reader.GetString, "city") member __.stateprovinceid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "stateprovinceid") - member __.addressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addressid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.postalcode = RequiredColumn(reader, getOrdinal, reader.GetString, "postalcode") + member __.spatiallocation = OptionalColumn(reader, getOrdinal, reader.GetString, "spatiallocation") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { addressline1 = __.addressline1.Read() - city = __.city.Read() + { addressid = __.addressid.Read() + addressline1 = __.addressline1.Read() addressline2 = __.addressline2.Read() - rowguid = __.rowguid.Read() - spatiallocation = __.spatiallocation.Read() + city = __.city.Read() stateprovinceid = __.stateprovinceid.Read() - addressid = __.addressid.Read() - modifieddate = __.modifieddate.Read() - postalcode = __.postalcode.Read() } + postalcode = __.postalcode.Read() + spatiallocation = __.spatiallocation.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.addressid.IsNull() then None else Some(__.Read()) [] type addresstype = - { rowguid: System.Guid - modifieddate: System.DateTime + { addresstypeid: int name: string - addresstypeid: int } + rowguid: System.Guid + modifieddate: System.DateTime } type addresstypeReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.addresstypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addresstypeid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.addresstypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addresstypeid") member __.Read() = - { rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() + { addresstypeid = __.addresstypeid.Read() name = __.name.Read() - addresstypeid = __.addresstypeid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.addresstypeid.IsNull() then None else Some(__.Read()) @@ -261,17 +261,17 @@ module person = [] type businessentity = { businessentityid: int - modifieddate: System.DateTime - rowguid: System.Guid } + rowguid: System.Guid + modifieddate: System.DateTime } type businessentityReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { businessentityid = __.businessentityid.Read() - modifieddate = __.modifieddate.Read() - rowguid = __.rowguid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) @@ -279,83 +279,83 @@ module person = [] type businessentityaddress = { businessentityid: int - modifieddate: System.DateTime + addressid: int addresstypeid: int rowguid: System.Guid - addressid: int } + modifieddate: System.DateTime } type businessentityaddressReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.addressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addressid") member __.addresstypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addresstypeid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.addressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "addressid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { businessentityid = __.businessentityid.Read() - modifieddate = __.modifieddate.Read() + addressid = __.addressid.Read() addresstypeid = __.addresstypeid.Read() rowguid = __.rowguid.Read() - addressid = __.addressid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type businessentitycontact = - { modifieddate: System.DateTime - businessentityid: int + { businessentityid: int personid: int + contacttypeid: int rowguid: System.Guid - contacttypeid: int } + modifieddate: System.DateTime } type businessentitycontactReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.personid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "personid") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.contacttypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "contacttypeid") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() + { businessentityid = __.businessentityid.Read() personid = __.personid.Read() + contacttypeid = __.contacttypeid.Read() rowguid = __.rowguid.Read() - contacttypeid = __.contacttypeid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type contacttype = - { modifieddate: System.DateTime + { contacttypeid: int name: string - contacttypeid: int } + modifieddate: System.DateTime } type contacttypeReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.contacttypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "contacttypeid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() + { contacttypeid = __.contacttypeid.Read() name = __.name.Read() - contacttypeid = __.contacttypeid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.contacttypeid.IsNull() then None else Some(__.Read()) [] type countryregion = - { name: string - modifieddate: System.DateTime - countryregioncode: string } + { countryregioncode: string + name: string + modifieddate: System.DateTime } type countryregionReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.countryregioncode = RequiredColumn(reader, getOrdinal, reader.GetString, "countryregioncode") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.countryregioncode = RequiredColumn(reader, getOrdinal, reader.GetString, "countryregioncode") member __.Read() = - { name = __.name.Read() - modifieddate = __.modifieddate.Read() - countryregioncode = __.countryregioncode.Read() } + { countryregioncode = __.countryregioncode.Read() + name = __.name.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.countryregioncode.IsNull() then None else Some(__.Read()) @@ -363,46 +363,46 @@ module person = [] type emailaddress = { businessentityid: int - modifieddate: System.DateTime + emailaddressid: int emailaddress: Option rowguid: System.Guid - emailaddressid: int } + modifieddate: System.DateTime } type emailaddressReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.emailaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "emailaddressid") member __.emailaddress = OptionalColumn(reader, getOrdinal, reader.GetString, "emailaddress") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.emailaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "emailaddressid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { businessentityid = __.businessentityid.Read() - modifieddate = __.modifieddate.Read() + emailaddressid = __.emailaddressid.Read() emailaddress = __.emailaddress.Read() rowguid = __.rowguid.Read() - emailaddressid = __.emailaddressid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type password = - { passwordsalt: string - rowguid: System.Guid + { businessentityid: int passwordhash: string - businessentityid: int + passwordsalt: string + rowguid: System.Guid modifieddate: System.DateTime } type passwordReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.passwordhash = RequiredColumn(reader, getOrdinal, reader.GetString, "passwordhash") member __.passwordsalt = RequiredColumn(reader, getOrdinal, reader.GetString, "passwordsalt") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.passwordhash = RequiredColumn(reader, getOrdinal, reader.GetString, "passwordhash") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { passwordsalt = __.passwordsalt.Read() - rowguid = __.rowguid.Read() + { businessentityid = __.businessentityid.Read() passwordhash = __.passwordhash.Read() - businessentityid = __.businessentityid.Read() + passwordsalt = __.passwordsalt.Read() + rowguid = __.rowguid.Read() modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = @@ -410,69 +410,69 @@ module person = [] type person = - { additionalcontactinfo: Option - suffix: Option - lastname: string + { businessentityid: int persontype: string - modifieddate: System.DateTime namestyle: bool title: Option - middlename: Option - rowguid: System.Guid - demographics: Option firstname: string + middlename: Option + lastname: string + suffix: Option emailpromotion: int - businessentityid: int } + additionalcontactinfo: Option + demographics: Option + rowguid: System.Guid + modifieddate: System.DateTime } type personReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.additionalcontactinfo = OptionalColumn(reader, getOrdinal, reader.GetString, "additionalcontactinfo") - member __.suffix = OptionalColumn(reader, getOrdinal, reader.GetString, "suffix") - member __.lastname = RequiredColumn(reader, getOrdinal, reader.GetString, "lastname") + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.persontype = RequiredColumn(reader, getOrdinal, reader.GetString, "persontype") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.namestyle = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "namestyle") member __.title = OptionalColumn(reader, getOrdinal, reader.GetString, "title") - member __.middlename = OptionalColumn(reader, getOrdinal, reader.GetString, "middlename") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.demographics = OptionalColumn(reader, getOrdinal, reader.GetString, "demographics") member __.firstname = RequiredColumn(reader, getOrdinal, reader.GetString, "firstname") + member __.middlename = OptionalColumn(reader, getOrdinal, reader.GetString, "middlename") + member __.lastname = RequiredColumn(reader, getOrdinal, reader.GetString, "lastname") + member __.suffix = OptionalColumn(reader, getOrdinal, reader.GetString, "suffix") member __.emailpromotion = RequiredColumn(reader, getOrdinal, reader.GetInt32, "emailpromotion") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.additionalcontactinfo = OptionalColumn(reader, getOrdinal, reader.GetString, "additionalcontactinfo") + member __.demographics = OptionalColumn(reader, getOrdinal, reader.GetString, "demographics") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { additionalcontactinfo = __.additionalcontactinfo.Read() - suffix = __.suffix.Read() - lastname = __.lastname.Read() + { businessentityid = __.businessentityid.Read() persontype = __.persontype.Read() - modifieddate = __.modifieddate.Read() namestyle = __.namestyle.Read() title = __.title.Read() - middlename = __.middlename.Read() - rowguid = __.rowguid.Read() - demographics = __.demographics.Read() firstname = __.firstname.Read() + middlename = __.middlename.Read() + lastname = __.lastname.Read() + suffix = __.suffix.Read() emailpromotion = __.emailpromotion.Read() - businessentityid = __.businessentityid.Read() } - - member __.ReadIfNotNull() = + additionalcontactinfo = __.additionalcontactinfo.Read() + demographics = __.demographics.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } + + member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type personphone = { businessentityid: int phonenumber: string - modifieddate: System.DateTime - phonenumbertypeid: int } + phonenumbertypeid: int + modifieddate: System.DateTime } type personphoneReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.phonenumber = RequiredColumn(reader, getOrdinal, reader.GetString, "phonenumber") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.phonenumbertypeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "phonenumbertypeid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { businessentityid = __.businessentityid.Read() phonenumber = __.phonenumber.Read() - modifieddate = __.modifieddate.Read() - phonenumbertypeid = __.phonenumbertypeid.Read() } + phonenumbertypeid = __.phonenumbertypeid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) @@ -497,33 +497,33 @@ module person = [] type stateprovince = - { name: string - stateprovinceid: int - territoryid: int + { stateprovinceid: int stateprovincecode: string - isonlystateprovinceflag: bool countryregioncode: string - modifieddate: System.DateTime - rowguid: System.Guid } + isonlystateprovinceflag: bool + name: string + territoryid: int + rowguid: System.Guid + modifieddate: System.DateTime } type stateprovinceReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.stateprovinceid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "stateprovinceid") - member __.territoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.stateprovincecode = RequiredColumn(reader, getOrdinal, reader.GetString, "stateprovincecode") - member __.isonlystateprovinceflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "isonlystateprovinceflag") member __.countryregioncode = RequiredColumn(reader, getOrdinal, reader.GetString, "countryregioncode") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.isonlystateprovinceflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "isonlystateprovinceflag") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.territoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { name = __.name.Read() - stateprovinceid = __.stateprovinceid.Read() - territoryid = __.territoryid.Read() + { stateprovinceid = __.stateprovinceid.Read() stateprovincecode = __.stateprovincecode.Read() - isonlystateprovinceflag = __.isonlystateprovinceflag.Read() countryregioncode = __.countryregioncode.Read() - modifieddate = __.modifieddate.Read() - rowguid = __.rowguid.Read() } + isonlystateprovinceflag = __.isonlystateprovinceflag.Read() + name = __.name.Read() + territoryid = __.territoryid.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.stateprovinceid.IsNull() then None else Some(__.Read()) @@ -531,120 +531,120 @@ module person = module production = [] type billofmaterials = - { enddate: Option - modifieddate: System.DateTime - billofmaterialsid: int - unitmeasurecode: string + { billofmaterialsid: int productassemblyid: Option componentid: int startdate: System.DateTime + enddate: Option + unitmeasurecode: string bomlevel: int16 - perassemblyqty: decimal } + perassemblyqty: decimal + modifieddate: System.DateTime } type billofmaterialsReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.billofmaterialsid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "billofmaterialsid") - member __.unitmeasurecode = RequiredColumn(reader, getOrdinal, reader.GetString, "unitmeasurecode") member __.productassemblyid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "productassemblyid") member __.componentid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "componentid") member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") + member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") + member __.unitmeasurecode = RequiredColumn(reader, getOrdinal, reader.GetString, "unitmeasurecode") member __.bomlevel = RequiredColumn(reader, getOrdinal, reader.GetInt16, "bomlevel") member __.perassemblyqty = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "perassemblyqty") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { enddate = __.enddate.Read() - modifieddate = __.modifieddate.Read() - billofmaterialsid = __.billofmaterialsid.Read() - unitmeasurecode = __.unitmeasurecode.Read() + { billofmaterialsid = __.billofmaterialsid.Read() productassemblyid = __.productassemblyid.Read() componentid = __.componentid.Read() startdate = __.startdate.Read() + enddate = __.enddate.Read() + unitmeasurecode = __.unitmeasurecode.Read() bomlevel = __.bomlevel.Read() - perassemblyqty = __.perassemblyqty.Read() } + perassemblyqty = __.perassemblyqty.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.billofmaterialsid.IsNull() then None else Some(__.Read()) [] type culture = - { modifieddate: System.DateTime + { cultureid: string name: string - cultureid: string } + modifieddate: System.DateTime } type cultureReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.cultureid = RequiredColumn(reader, getOrdinal, reader.GetString, "cultureid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() + { cultureid = __.cultureid.Read() name = __.name.Read() - cultureid = __.cultureid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.cultureid.IsNull() then None else Some(__.Read()) [] type document = - { revision: string - fileextension: Option - status: int16 - title: string - modifieddate: System.DateTime + { title: string owner: int - rowguid: System.Guid + folderflag: bool filename: string - documentnode: string + fileextension: Option + revision: string changenumber: int + status: int16 documentsummary: Option document: Option - folderflag: bool } + rowguid: System.Guid + modifieddate: System.DateTime + documentnode: string } type documentReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.revision = RequiredColumn(reader, getOrdinal, reader.GetString, "revision") - member __.fileextension = OptionalColumn(reader, getOrdinal, reader.GetString, "fileextension") - member __.status = RequiredColumn(reader, getOrdinal, reader.GetInt16, "status") member __.title = RequiredColumn(reader, getOrdinal, reader.GetString, "title") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.owner = RequiredColumn(reader, getOrdinal, reader.GetInt32, "owner") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.folderflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "folderflag") member __.filename = RequiredColumn(reader, getOrdinal, reader.GetString, "filename") - member __.documentnode = RequiredColumn(reader, getOrdinal, reader.GetString, "documentnode") + member __.fileextension = OptionalColumn(reader, getOrdinal, reader.GetString, "fileextension") + member __.revision = RequiredColumn(reader, getOrdinal, reader.GetString, "revision") member __.changenumber = RequiredColumn(reader, getOrdinal, reader.GetInt32, "changenumber") + member __.status = RequiredColumn(reader, getOrdinal, reader.GetInt16, "status") member __.documentsummary = OptionalColumn(reader, getOrdinal, reader.GetString, "documentsummary") member __.document = OptionalBinaryColumn(reader, getOrdinal, reader.GetValue, "document") - member __.folderflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "folderflag") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.documentnode = RequiredColumn(reader, getOrdinal, reader.GetString, "documentnode") member __.Read() = - { revision = __.revision.Read() - fileextension = __.fileextension.Read() - status = __.status.Read() - title = __.title.Read() - modifieddate = __.modifieddate.Read() + { title = __.title.Read() owner = __.owner.Read() - rowguid = __.rowguid.Read() + folderflag = __.folderflag.Read() filename = __.filename.Read() - documentnode = __.documentnode.Read() + fileextension = __.fileextension.Read() + revision = __.revision.Read() changenumber = __.changenumber.Read() + status = __.status.Read() documentsummary = __.documentsummary.Read() document = __.document.Read() - folderflag = __.folderflag.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() + documentnode = __.documentnode.Read() } member __.ReadIfNotNull() = if __.documentnode.IsNull() then None else Some(__.Read()) [] type illustration = - { diagram: Option - modifieddate: System.DateTime - illustrationid: int } + { illustrationid: int + diagram: Option + modifieddate: System.DateTime } type illustrationReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.illustrationid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "illustrationid") member __.diagram = OptionalColumn(reader, getOrdinal, reader.GetString, "diagram") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.illustrationid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "illustrationid") member __.Read() = - { diagram = __.diagram.Read() - modifieddate = __.modifieddate.Read() - illustrationid = __.illustrationid.Read() } + { illustrationid = __.illustrationid.Read() + diagram = __.diagram.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.illustrationid.IsNull() then None else Some(__.Read()) @@ -652,311 +652,311 @@ module production = [] type location = { locationid: int - modifieddate: System.DateTime + name: string costrate: decimal availability: decimal - name: string } + modifieddate: System.DateTime } type locationReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.locationid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "locationid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.costrate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "costrate") member __.availability = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "availability") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { locationid = __.locationid.Read() - modifieddate = __.modifieddate.Read() + name = __.name.Read() costrate = __.costrate.Read() availability = __.availability.Read() - name = __.name.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.locationid.IsNull() then None else Some(__.Read()) [] type product = - { finishedgoodsflag: bool - productmodelid: Option + { productid: int + name: string + productnumber: string + makeflag: bool + finishedgoodsflag: bool + color: Option + safetystocklevel: int16 + reorderpoint: int16 + standardcost: decimal + listprice: decimal size: Option sizeunitmeasurecode: Option - productid: int - sellenddate: Option - standardcost: decimal + weightunitmeasurecode: Option + weight: Option daystomanufacture: int - sellstartdate: System.DateTime - modifieddate: System.DateTime + productline: Option ``class``: Option - color: Option - weightunitmeasurecode: Option - productsubcategoryid: Option - name: string style: Option - makeflag: bool - productline: Option - weight: Option - productnumber: string - rowguid: System.Guid - listprice: decimal + productsubcategoryid: Option + productmodelid: Option + sellstartdate: System.DateTime + sellenddate: Option discontinueddate: Option - safetystocklevel: int16 - reorderpoint: int16 } + rowguid: System.Guid + modifieddate: System.DateTime } type productReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.productnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "productnumber") + member __.makeflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "makeflag") member __.finishedgoodsflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "finishedgoodsflag") - member __.productmodelid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "productmodelid") + member __.color = OptionalColumn(reader, getOrdinal, reader.GetString, "color") + member __.safetystocklevel = RequiredColumn(reader, getOrdinal, reader.GetInt16, "safetystocklevel") + member __.reorderpoint = RequiredColumn(reader, getOrdinal, reader.GetInt16, "reorderpoint") + member __.standardcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "standardcost") + member __.listprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "listprice") member __.size = OptionalColumn(reader, getOrdinal, reader.GetString, "size") member __.sizeunitmeasurecode = OptionalColumn(reader, getOrdinal, reader.GetString, "sizeunitmeasurecode") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.sellenddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "sellenddate") - member __.standardcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "standardcost") + member __.weightunitmeasurecode = OptionalColumn(reader, getOrdinal, reader.GetString, "weightunitmeasurecode") + member __.weight = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "weight") member __.daystomanufacture = RequiredColumn(reader, getOrdinal, reader.GetInt32, "daystomanufacture") - member __.sellstartdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "sellstartdate") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.productline = OptionalColumn(reader, getOrdinal, reader.GetString, "productline") member __.``class`` = OptionalColumn(reader, getOrdinal, reader.GetString, "class") - member __.color = OptionalColumn(reader, getOrdinal, reader.GetString, "color") - member __.weightunitmeasurecode = OptionalColumn(reader, getOrdinal, reader.GetString, "weightunitmeasurecode") - member __.productsubcategoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "productsubcategoryid") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.style = OptionalColumn(reader, getOrdinal, reader.GetString, "style") - member __.makeflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "makeflag") - member __.productline = OptionalColumn(reader, getOrdinal, reader.GetString, "productline") - member __.weight = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "weight") - member __.productnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "productnumber") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.listprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "listprice") + member __.productsubcategoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "productsubcategoryid") + member __.productmodelid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "productmodelid") + member __.sellstartdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "sellstartdate") + member __.sellenddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "sellenddate") member __.discontinueddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "discontinueddate") - member __.safetystocklevel = RequiredColumn(reader, getOrdinal, reader.GetInt16, "safetystocklevel") - member __.reorderpoint = RequiredColumn(reader, getOrdinal, reader.GetInt16, "reorderpoint") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { finishedgoodsflag = __.finishedgoodsflag.Read() - productmodelid = __.productmodelid.Read() + { productid = __.productid.Read() + name = __.name.Read() + productnumber = __.productnumber.Read() + makeflag = __.makeflag.Read() + finishedgoodsflag = __.finishedgoodsflag.Read() + color = __.color.Read() + safetystocklevel = __.safetystocklevel.Read() + reorderpoint = __.reorderpoint.Read() + standardcost = __.standardcost.Read() + listprice = __.listprice.Read() size = __.size.Read() sizeunitmeasurecode = __.sizeunitmeasurecode.Read() - productid = __.productid.Read() - sellenddate = __.sellenddate.Read() - standardcost = __.standardcost.Read() + weightunitmeasurecode = __.weightunitmeasurecode.Read() + weight = __.weight.Read() daystomanufacture = __.daystomanufacture.Read() - sellstartdate = __.sellstartdate.Read() - modifieddate = __.modifieddate.Read() + productline = __.productline.Read() ``class`` = __.``class``.Read() - color = __.color.Read() - weightunitmeasurecode = __.weightunitmeasurecode.Read() - productsubcategoryid = __.productsubcategoryid.Read() - name = __.name.Read() style = __.style.Read() - makeflag = __.makeflag.Read() - productline = __.productline.Read() - weight = __.weight.Read() - productnumber = __.productnumber.Read() - rowguid = __.rowguid.Read() - listprice = __.listprice.Read() + productsubcategoryid = __.productsubcategoryid.Read() + productmodelid = __.productmodelid.Read() + sellstartdate = __.sellstartdate.Read() + sellenddate = __.sellenddate.Read() discontinueddate = __.discontinueddate.Read() - safetystocklevel = __.safetystocklevel.Read() - reorderpoint = __.reorderpoint.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productid.IsNull() then None else Some(__.Read()) [] type productcategory = - { name: string + { productcategoryid: int + name: string rowguid: System.Guid - modifieddate: System.DateTime - productcategoryid: int } + modifieddate: System.DateTime } type productcategoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.productcategoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productcategoryid") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.productcategoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productcategoryid") member __.Read() = - { name = __.name.Read() + { productcategoryid = __.productcategoryid.Read() + name = __.name.Read() rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() - productcategoryid = __.productcategoryid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productcategoryid.IsNull() then None else Some(__.Read()) [] type productcosthistory = - { startdate: System.DateTime + { productid: int + startdate: System.DateTime enddate: Option standardcost: decimal - modifieddate: System.DateTime - productid: int } + modifieddate: System.DateTime } type productcosthistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") member __.standardcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "standardcost") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.Read() = - { startdate = __.startdate.Read() + { productid = __.productid.Read() + startdate = __.startdate.Read() enddate = __.enddate.Read() standardcost = __.standardcost.Read() - modifieddate = __.modifieddate.Read() - productid = __.productid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.startdate.IsNull() then None else Some(__.Read()) + if __.productid.IsNull() then None else Some(__.Read()) [] type productdescription = { productdescriptionid: int description: string - modifieddate: System.DateTime - rowguid: System.Guid } + rowguid: System.Guid + modifieddate: System.DateTime } type productdescriptionReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.productdescriptionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productdescriptionid") member __.description = RequiredColumn(reader, getOrdinal, reader.GetString, "description") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { productdescriptionid = __.productdescriptionid.Read() description = __.description.Read() - modifieddate = __.modifieddate.Read() - rowguid = __.rowguid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productdescriptionid.IsNull() then None else Some(__.Read()) [] type productdocument = - { modifieddate: System.DateTime - documentnode: string - productid: int } + { productid: int + modifieddate: System.DateTime + documentnode: string } type productdocumentReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.documentnode = RequiredColumn(reader, getOrdinal, reader.GetString, "documentnode") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.Read() = - { modifieddate = __.modifieddate.Read() - documentnode = __.documentnode.Read() - productid = __.productid.Read() } + { productid = __.productid.Read() + modifieddate = __.modifieddate.Read() + documentnode = __.documentnode.Read() } member __.ReadIfNotNull() = - if __.documentnode.IsNull() then None else Some(__.Read()) + if __.productid.IsNull() then None else Some(__.Read()) [] type productinventory = - { rowguid: System.Guid - productid: int - quantity: int16 - modifieddate: System.DateTime + { productid: int + locationid: int16 shelf: string bin: int16 - locationid: int16 } + quantity: int16 + rowguid: System.Guid + modifieddate: System.DateTime } type productinventoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt16, "quantity") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.locationid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "locationid") member __.shelf = RequiredColumn(reader, getOrdinal, reader.GetString, "shelf") member __.bin = RequiredColumn(reader, getOrdinal, reader.GetInt16, "bin") - member __.locationid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "locationid") + member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt16, "quantity") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { rowguid = __.rowguid.Read() - productid = __.productid.Read() - quantity = __.quantity.Read() - modifieddate = __.modifieddate.Read() + { productid = __.productid.Read() + locationid = __.locationid.Read() shelf = __.shelf.Read() bin = __.bin.Read() - locationid = __.locationid.Read() } + quantity = __.quantity.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productid.IsNull() then None else Some(__.Read()) [] type productlistpricehistory = - { enddate: Option - listprice: decimal + { productid: int startdate: System.DateTime - productid: int + enddate: Option + listprice: decimal modifieddate: System.DateTime } type productlistpricehistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") member __.listprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "listprice") - member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { enddate = __.enddate.Read() - listprice = __.listprice.Read() + { productid = __.productid.Read() startdate = __.startdate.Read() - productid = __.productid.Read() + enddate = __.enddate.Read() + listprice = __.listprice.Read() modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.startdate.IsNull() then None else Some(__.Read()) + if __.productid.IsNull() then None else Some(__.Read()) [] type productmodel = - { modifieddate: System.DateTime - rowguid: System.Guid - productmodelid: int + { productmodelid: int name: string catalogdescription: Option - instructions: Option } + instructions: Option + rowguid: System.Guid + modifieddate: System.DateTime } type productmodelReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.productmodelid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productmodelid") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.catalogdescription = OptionalColumn(reader, getOrdinal, reader.GetString, "catalogdescription") member __.instructions = OptionalColumn(reader, getOrdinal, reader.GetString, "instructions") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - rowguid = __.rowguid.Read() - productmodelid = __.productmodelid.Read() + { productmodelid = __.productmodelid.Read() name = __.name.Read() catalogdescription = __.catalogdescription.Read() - instructions = __.instructions.Read() } + instructions = __.instructions.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productmodelid.IsNull() then None else Some(__.Read()) [] type productmodelillustration = - { modifieddate: System.DateTime + { productmodelid: int illustrationid: int - productmodelid: int } + modifieddate: System.DateTime } type productmodelillustrationReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.illustrationid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "illustrationid") member __.productmodelid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productmodelid") + member __.illustrationid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "illustrationid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() + { productmodelid = __.productmodelid.Read() illustrationid = __.illustrationid.Read() - productmodelid = __.productmodelid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.illustrationid.IsNull() then None else Some(__.Read()) + if __.productmodelid.IsNull() then None else Some(__.Read()) [] type productmodelproductdescriptionculture = { productmodelid: int - modifieddate: System.DateTime + productdescriptionid: int cultureid: string - productdescriptionid: int } + modifieddate: System.DateTime } type productmodelproductdescriptioncultureReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.productmodelid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productmodelid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.cultureid = RequiredColumn(reader, getOrdinal, reader.GetString, "cultureid") member __.productdescriptionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productdescriptionid") + member __.cultureid = RequiredColumn(reader, getOrdinal, reader.GetString, "cultureid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { productmodelid = __.productmodelid.Read() - modifieddate = __.modifieddate.Read() + productdescriptionid = __.productdescriptionid.Read() cultureid = __.cultureid.Read() - productdescriptionid = __.productdescriptionid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productmodelid.IsNull() then None else Some(__.Read()) @@ -964,26 +964,26 @@ module production = [] type productphoto = { productphotoid: int - largephotofilename: Option - modifieddate: System.DateTime + thumbnailphoto: Option thumbnailphotofilename: Option largephoto: Option - thumbnailphoto: Option } + largephotofilename: Option + modifieddate: System.DateTime } type productphotoReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.productphotoid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productphotoid") - member __.largephotofilename = OptionalColumn(reader, getOrdinal, reader.GetString, "largephotofilename") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.thumbnailphoto = OptionalBinaryColumn(reader, getOrdinal, reader.GetValue, "thumbnailphoto") member __.thumbnailphotofilename = OptionalColumn(reader, getOrdinal, reader.GetString, "thumbnailphotofilename") member __.largephoto = OptionalBinaryColumn(reader, getOrdinal, reader.GetValue, "largephoto") - member __.thumbnailphoto = OptionalBinaryColumn(reader, getOrdinal, reader.GetValue, "thumbnailphoto") + member __.largephotofilename = OptionalColumn(reader, getOrdinal, reader.GetString, "largephotofilename") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { productphotoid = __.productphotoid.Read() - largephotofilename = __.largephotofilename.Read() - modifieddate = __.modifieddate.Read() + thumbnailphoto = __.thumbnailphoto.Read() thumbnailphotofilename = __.thumbnailphotofilename.Read() largephoto = __.largephoto.Read() - thumbnailphoto = __.thumbnailphoto.Read() } + largephotofilename = __.largephotofilename.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productphotoid.IsNull() then None else Some(__.Read()) @@ -991,53 +991,53 @@ module production = [] type productproductphoto = { productid: int - modifieddate: System.DateTime + productphotoid: int primary: bool - productphotoid: int } + modifieddate: System.DateTime } type productproductphotoReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.primary = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "primary") member __.productphotoid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productphotoid") + member __.primary = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "primary") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { productid = __.productid.Read() - modifieddate = __.modifieddate.Read() + productphotoid = __.productphotoid.Read() primary = __.primary.Read() - productphotoid = __.productphotoid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productid.IsNull() then None else Some(__.Read()) [] type productreview = - { comments: Option - modifieddate: System.DateTime + { productreviewid: int productid: int - reviewdate: System.DateTime reviewername: string - rating: int + reviewdate: System.DateTime emailaddress: string - productreviewid: int } + rating: int + comments: Option + modifieddate: System.DateTime } type productreviewReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.comments = OptionalColumn(reader, getOrdinal, reader.GetString, "comments") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.productreviewid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productreviewid") member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.reviewdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "reviewdate") member __.reviewername = RequiredColumn(reader, getOrdinal, reader.GetString, "reviewername") - member __.rating = RequiredColumn(reader, getOrdinal, reader.GetInt32, "rating") + member __.reviewdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "reviewdate") member __.emailaddress = RequiredColumn(reader, getOrdinal, reader.GetString, "emailaddress") - member __.productreviewid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productreviewid") + member __.rating = RequiredColumn(reader, getOrdinal, reader.GetInt32, "rating") + member __.comments = OptionalColumn(reader, getOrdinal, reader.GetString, "comments") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { comments = __.comments.Read() - modifieddate = __.modifieddate.Read() + { productreviewid = __.productreviewid.Read() productid = __.productid.Read() - reviewdate = __.reviewdate.Read() reviewername = __.reviewername.Read() - rating = __.rating.Read() + reviewdate = __.reviewdate.Read() emailaddress = __.emailaddress.Read() - productreviewid = __.productreviewid.Read() } + rating = __.rating.Read() + comments = __.comments.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productreviewid.IsNull() then None else Some(__.Read()) @@ -1045,113 +1045,113 @@ module production = [] type productsubcategory = { productsubcategoryid: int - modifieddate: System.DateTime - rowguid: System.Guid + productcategoryid: int name: string - productcategoryid: int } + rowguid: System.Guid + modifieddate: System.DateTime } type productsubcategoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.productsubcategoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productsubcategoryid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.productcategoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productcategoryid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { productsubcategoryid = __.productsubcategoryid.Read() - modifieddate = __.modifieddate.Read() - rowguid = __.rowguid.Read() + productcategoryid = __.productcategoryid.Read() name = __.name.Read() - productcategoryid = __.productcategoryid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.productsubcategoryid.IsNull() then None else Some(__.Read()) [] type scrapreason = - { name: string - modifieddate: System.DateTime - scrapreasonid: int } + { scrapreasonid: int + name: string + modifieddate: System.DateTime } type scrapreasonReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.scrapreasonid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "scrapreasonid") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.scrapreasonid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "scrapreasonid") member __.Read() = - { name = __.name.Read() - modifieddate = __.modifieddate.Read() - scrapreasonid = __.scrapreasonid.Read() } + { scrapreasonid = __.scrapreasonid.Read() + name = __.name.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.scrapreasonid.IsNull() then None else Some(__.Read()) [] type transactionhistory = - { productid: int - referenceorderlineid: int + { transactionid: int + productid: int referenceorderid: int - actualcost: decimal - quantity: int + referenceorderlineid: int transactiondate: System.DateTime - transactionid: int - modifieddate: System.DateTime - transactiontype: string } + transactiontype: string + quantity: int + actualcost: decimal + modifieddate: System.DateTime } type transactionhistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.transactionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "transactionid") member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.referenceorderlineid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "referenceorderlineid") member __.referenceorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "referenceorderid") - member __.actualcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "actualcost") - member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt32, "quantity") + member __.referenceorderlineid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "referenceorderlineid") member __.transactiondate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "transactiondate") - member __.transactionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "transactionid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.transactiontype = RequiredColumn(reader, getOrdinal, reader.GetString, "transactiontype") + member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt32, "quantity") + member __.actualcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "actualcost") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { productid = __.productid.Read() - referenceorderlineid = __.referenceorderlineid.Read() + { transactionid = __.transactionid.Read() + productid = __.productid.Read() referenceorderid = __.referenceorderid.Read() - actualcost = __.actualcost.Read() - quantity = __.quantity.Read() + referenceorderlineid = __.referenceorderlineid.Read() transactiondate = __.transactiondate.Read() - transactionid = __.transactionid.Read() - modifieddate = __.modifieddate.Read() - transactiontype = __.transactiontype.Read() } + transactiontype = __.transactiontype.Read() + quantity = __.quantity.Read() + actualcost = __.actualcost.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.transactionid.IsNull() then None else Some(__.Read()) [] type transactionhistoryarchive = - { referenceorderid: int - referenceorderlineid: int + { transactionid: int productid: int + referenceorderid: int + referenceorderlineid: int + transactiondate: System.DateTime + transactiontype: string quantity: int actualcost: decimal - modifieddate: System.DateTime - transactionid: int - transactiondate: System.DateTime - transactiontype: string } + modifieddate: System.DateTime } type transactionhistoryarchiveReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.transactionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "transactionid") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.referenceorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "referenceorderid") member __.referenceorderlineid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "referenceorderlineid") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.transactiondate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "transactiondate") + member __.transactiontype = RequiredColumn(reader, getOrdinal, reader.GetString, "transactiontype") member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt32, "quantity") member __.actualcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "actualcost") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.transactionid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "transactionid") - member __.transactiondate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "transactiondate") - member __.transactiontype = RequiredColumn(reader, getOrdinal, reader.GetString, "transactiontype") member __.Read() = - { referenceorderid = __.referenceorderid.Read() - referenceorderlineid = __.referenceorderlineid.Read() + { transactionid = __.transactionid.Read() productid = __.productid.Read() + referenceorderid = __.referenceorderid.Read() + referenceorderlineid = __.referenceorderlineid.Read() + transactiondate = __.transactiondate.Read() + transactiontype = __.transactiontype.Read() quantity = __.quantity.Read() actualcost = __.actualcost.Read() - modifieddate = __.modifieddate.Read() - transactionid = __.transactionid.Read() - transactiondate = __.transactiondate.Read() - transactiontype = __.transactiontype.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.transactionid.IsNull() then None else Some(__.Read()) @@ -1159,282 +1159,303 @@ module production = [] type unitmeasure = { unitmeasurecode: string - modifieddate: System.DateTime - name: string } + name: string + modifieddate: System.DateTime } type unitmeasureReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.unitmeasurecode = RequiredColumn(reader, getOrdinal, reader.GetString, "unitmeasurecode") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { unitmeasurecode = __.unitmeasurecode.Read() - modifieddate = __.modifieddate.Read() - name = __.name.Read() } + name = __.name.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.unitmeasurecode.IsNull() then None else Some(__.Read()) [] type workorder = - { duedate: System.DateTime - enddate: Option - modifieddate: System.DateTime - orderqty: int + { workorderid: int productid: int + orderqty: int + scrappedqty: int16 startdate: System.DateTime - workorderid: int + enddate: Option + duedate: System.DateTime scrapreasonid: Option - scrappedqty: int16 } + modifieddate: System.DateTime } type workorderReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.duedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "duedate") - member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.orderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "orderqty") + member __.workorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "workorderid") member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.orderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "orderqty") + member __.scrappedqty = RequiredColumn(reader, getOrdinal, reader.GetInt16, "scrappedqty") member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") - member __.workorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "workorderid") + member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") + member __.duedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "duedate") member __.scrapreasonid = OptionalColumn(reader, getOrdinal, reader.GetInt16, "scrapreasonid") - member __.scrappedqty = RequiredColumn(reader, getOrdinal, reader.GetInt16, "scrappedqty") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { duedate = __.duedate.Read() - enddate = __.enddate.Read() - modifieddate = __.modifieddate.Read() - orderqty = __.orderqty.Read() + { workorderid = __.workorderid.Read() productid = __.productid.Read() + orderqty = __.orderqty.Read() + scrappedqty = __.scrappedqty.Read() startdate = __.startdate.Read() - workorderid = __.workorderid.Read() + enddate = __.enddate.Read() + duedate = __.duedate.Read() scrapreasonid = __.scrapreasonid.Read() - scrappedqty = __.scrappedqty.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.workorderid.IsNull() then None else Some(__.Read()) [] type workorderrouting = - { scheduledenddate: System.DateTime - workorderid: int - actualresourcehrs: Option + { workorderid: int + productid: int + operationsequence: int16 + locationid: int16 scheduledstartdate: System.DateTime - actualcost: Option - modifieddate: System.DateTime + scheduledenddate: System.DateTime actualstartdate: Option actualenddate: Option + actualresourcehrs: Option plannedcost: decimal - locationid: int16 - operationsequence: int16 - productid: int } + actualcost: Option + modifieddate: System.DateTime } type workorderroutingReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.scheduledenddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "scheduledenddate") member __.workorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "workorderid") - member __.actualresourcehrs = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "actualresourcehrs") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.operationsequence = RequiredColumn(reader, getOrdinal, reader.GetInt16, "operationsequence") + member __.locationid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "locationid") member __.scheduledstartdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "scheduledstartdate") - member __.actualcost = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "actualcost") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.scheduledenddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "scheduledenddate") member __.actualstartdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "actualstartdate") member __.actualenddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "actualenddate") + member __.actualresourcehrs = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "actualresourcehrs") member __.plannedcost = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "plannedcost") - member __.locationid = RequiredColumn(reader, getOrdinal, reader.GetInt16, "locationid") - member __.operationsequence = RequiredColumn(reader, getOrdinal, reader.GetInt16, "operationsequence") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.actualcost = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "actualcost") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { scheduledenddate = __.scheduledenddate.Read() - workorderid = __.workorderid.Read() - actualresourcehrs = __.actualresourcehrs.Read() + { workorderid = __.workorderid.Read() + productid = __.productid.Read() + operationsequence = __.operationsequence.Read() + locationid = __.locationid.Read() scheduledstartdate = __.scheduledstartdate.Read() - actualcost = __.actualcost.Read() - modifieddate = __.modifieddate.Read() + scheduledenddate = __.scheduledenddate.Read() actualstartdate = __.actualstartdate.Read() actualenddate = __.actualenddate.Read() + actualresourcehrs = __.actualresourcehrs.Read() plannedcost = __.plannedcost.Read() - locationid = __.locationid.Read() - operationsequence = __.operationsequence.Read() - productid = __.productid.Read() } + actualcost = __.actualcost.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.workorderid.IsNull() then None else Some(__.Read()) +module providerdbtypetest = + [] + type test = + { id: int + [] + json_field: string + [] + jsonb_field: string } + + type testReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.id = RequiredColumn(reader, getOrdinal, reader.GetInt32, "id") + member __.json_field = RequiredColumn(reader, getOrdinal, reader.GetString, "json_field") + member __.jsonb_field = RequiredColumn(reader, getOrdinal, reader.GetString, "jsonb_field") + member __.Read() = + { id = __.id.Read() + json_field = __.json_field.Read() + jsonb_field = __.jsonb_field.Read() } + + member __.ReadIfNotNull() = + if __.id.IsNull() then None else Some(__.Read()) + module purchasing = [] type productvendor = - { minorderqty: int - maxorderqty: int - unitmeasurecode: string + { productid: int + businessentityid: int averageleadtime: int standardprice: decimal - businessentityid: int + lastreceiptcost: Option lastreceiptdate: Option + minorderqty: int + maxorderqty: int onorderqty: Option - productid: int - lastreceiptcost: Option + unitmeasurecode: string modifieddate: System.DateTime } type productvendorReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.minorderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "minorderqty") - member __.maxorderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "maxorderqty") - member __.unitmeasurecode = RequiredColumn(reader, getOrdinal, reader.GetString, "unitmeasurecode") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.averageleadtime = RequiredColumn(reader, getOrdinal, reader.GetInt32, "averageleadtime") member __.standardprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "standardprice") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.lastreceiptcost = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "lastreceiptcost") member __.lastreceiptdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "lastreceiptdate") + member __.minorderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "minorderqty") + member __.maxorderqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "maxorderqty") member __.onorderqty = OptionalColumn(reader, getOrdinal, reader.GetInt32, "onorderqty") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.lastreceiptcost = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "lastreceiptcost") + member __.unitmeasurecode = RequiredColumn(reader, getOrdinal, reader.GetString, "unitmeasurecode") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { minorderqty = __.minorderqty.Read() - maxorderqty = __.maxorderqty.Read() - unitmeasurecode = __.unitmeasurecode.Read() + { productid = __.productid.Read() + businessentityid = __.businessentityid.Read() averageleadtime = __.averageleadtime.Read() standardprice = __.standardprice.Read() - businessentityid = __.businessentityid.Read() + lastreceiptcost = __.lastreceiptcost.Read() lastreceiptdate = __.lastreceiptdate.Read() + minorderqty = __.minorderqty.Read() + maxorderqty = __.maxorderqty.Read() onorderqty = __.onorderqty.Read() - productid = __.productid.Read() - lastreceiptcost = __.lastreceiptcost.Read() + unitmeasurecode = __.unitmeasurecode.Read() modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.businessentityid.IsNull() then None else Some(__.Read()) + if __.productid.IsNull() then None else Some(__.Read()) [] type purchaseorderdetail = - { unitprice: decimal - rejectedqty: decimal - purchaseorderid: int - productid: int - modifieddate: System.DateTime - receivedqty: decimal + { purchaseorderid: int + purchaseorderdetailid: int duedate: System.DateTime orderqty: int16 - purchaseorderdetailid: int } + productid: int + unitprice: decimal + receivedqty: decimal + rejectedqty: decimal + modifieddate: System.DateTime } type purchaseorderdetailReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.unitprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitprice") - member __.rejectedqty = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "rejectedqty") member __.purchaseorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "purchaseorderid") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.receivedqty = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "receivedqty") + member __.purchaseorderdetailid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "purchaseorderdetailid") member __.duedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "duedate") member __.orderqty = RequiredColumn(reader, getOrdinal, reader.GetInt16, "orderqty") - member __.purchaseorderdetailid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "purchaseorderdetailid") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.unitprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitprice") + member __.receivedqty = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "receivedqty") + member __.rejectedqty = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "rejectedqty") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { unitprice = __.unitprice.Read() - rejectedqty = __.rejectedqty.Read() - purchaseorderid = __.purchaseorderid.Read() - productid = __.productid.Read() - modifieddate = __.modifieddate.Read() - receivedqty = __.receivedqty.Read() + { purchaseorderid = __.purchaseorderid.Read() + purchaseorderdetailid = __.purchaseorderdetailid.Read() duedate = __.duedate.Read() orderqty = __.orderqty.Read() - purchaseorderdetailid = __.purchaseorderdetailid.Read() } + productid = __.productid.Read() + unitprice = __.unitprice.Read() + receivedqty = __.receivedqty.Read() + rejectedqty = __.rejectedqty.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.purchaseorderid.IsNull() then None else Some(__.Read()) [] type purchaseorderheader = - { revisionnumber: int16 - modifieddate: System.DateTime + { purchaseorderid: int + revisionnumber: int16 status: int16 employeeid: int - taxamt: decimal - shipdate: Option - orderdate: System.DateTime - freight: decimal vendorid: int + shipmethodid: int + orderdate: System.DateTime + shipdate: Option subtotal: decimal - purchaseorderid: int - shipmethodid: int } + taxamt: decimal + freight: decimal + modifieddate: System.DateTime } type purchaseorderheaderReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.purchaseorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "purchaseorderid") member __.revisionnumber = RequiredColumn(reader, getOrdinal, reader.GetInt16, "revisionnumber") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.status = RequiredColumn(reader, getOrdinal, reader.GetInt16, "status") member __.employeeid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "employeeid") - member __.taxamt = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxamt") - member __.shipdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "shipdate") - member __.orderdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "orderdate") - member __.freight = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "freight") member __.vendorid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "vendorid") - member __.subtotal = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "subtotal") - member __.purchaseorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "purchaseorderid") member __.shipmethodid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shipmethodid") + member __.orderdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "orderdate") + member __.shipdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "shipdate") + member __.subtotal = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "subtotal") + member __.taxamt = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxamt") + member __.freight = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "freight") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { revisionnumber = __.revisionnumber.Read() - modifieddate = __.modifieddate.Read() + { purchaseorderid = __.purchaseorderid.Read() + revisionnumber = __.revisionnumber.Read() status = __.status.Read() employeeid = __.employeeid.Read() - taxamt = __.taxamt.Read() - shipdate = __.shipdate.Read() - orderdate = __.orderdate.Read() - freight = __.freight.Read() vendorid = __.vendorid.Read() + shipmethodid = __.shipmethodid.Read() + orderdate = __.orderdate.Read() + shipdate = __.shipdate.Read() subtotal = __.subtotal.Read() - purchaseorderid = __.purchaseorderid.Read() - shipmethodid = __.shipmethodid.Read() } + taxamt = __.taxamt.Read() + freight = __.freight.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.purchaseorderid.IsNull() then None else Some(__.Read()) [] type shipmethod = - { rowguid: System.Guid - shipmethodid: int - modifieddate: System.DateTime + { shipmethodid: int name: string shipbase: decimal - shiprate: decimal } + shiprate: decimal + rowguid: System.Guid + modifieddate: System.DateTime } type shipmethodReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.shipmethodid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shipmethodid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.shipbase = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "shipbase") member __.shiprate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "shiprate") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { rowguid = __.rowguid.Read() - shipmethodid = __.shipmethodid.Read() - modifieddate = __.modifieddate.Read() + { shipmethodid = __.shipmethodid.Read() name = __.name.Read() shipbase = __.shipbase.Read() - shiprate = __.shiprate.Read() } + shiprate = __.shiprate.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.shipmethodid.IsNull() then None else Some(__.Read()) [] type vendor = - { purchasingwebserviceurl: Option - modifieddate: System.DateTime + { businessentityid: int accountnumber: string name: string creditrating: int16 - activeflag: bool preferredvendorstatus: bool - businessentityid: int } + activeflag: bool + purchasingwebserviceurl: Option + modifieddate: System.DateTime } type vendorReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.purchasingwebserviceurl = OptionalColumn(reader, getOrdinal, reader.GetString, "purchasingwebserviceurl") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.accountnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "accountnumber") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.creditrating = RequiredColumn(reader, getOrdinal, reader.GetInt16, "creditrating") - member __.activeflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "activeflag") member __.preferredvendorstatus = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "preferredvendorstatus") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.activeflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "activeflag") + member __.purchasingwebserviceurl = OptionalColumn(reader, getOrdinal, reader.GetString, "purchasingwebserviceurl") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { purchasingwebserviceurl = __.purchasingwebserviceurl.Read() - modifieddate = __.modifieddate.Read() + { businessentityid = __.businessentityid.Read() accountnumber = __.accountnumber.Read() name = __.name.Read() creditrating = __.creditrating.Read() - activeflag = __.activeflag.Read() preferredvendorstatus = __.preferredvendorstatus.Read() - businessentityid = __.businessentityid.Read() } + activeflag = __.activeflag.Read() + purchasingwebserviceurl = __.purchasingwebserviceurl.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) @@ -1442,261 +1463,261 @@ module purchasing = module sales = [] type countryregioncurrency = - { modifieddate: System.DateTime + { countryregioncode: string currencycode: string - countryregioncode: string } + modifieddate: System.DateTime } type countryregioncurrencyReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.currencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "currencycode") member __.countryregioncode = RequiredColumn(reader, getOrdinal, reader.GetString, "countryregioncode") + member __.currencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "currencycode") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() + { countryregioncode = __.countryregioncode.Read() currencycode = __.currencycode.Read() - countryregioncode = __.countryregioncode.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.currencycode.IsNull() then None else Some(__.Read()) + if __.countryregioncode.IsNull() then None else Some(__.Read()) [] type creditcard = - { modifieddate: System.DateTime - creditcardid: int - expyear: int16 - expmonth: int16 + { creditcardid: int + cardtype: string cardnumber: string - cardtype: string } + expmonth: int16 + expyear: int16 + modifieddate: System.DateTime } type creditcardReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.creditcardid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "creditcardid") - member __.expyear = RequiredColumn(reader, getOrdinal, reader.GetInt16, "expyear") - member __.expmonth = RequiredColumn(reader, getOrdinal, reader.GetInt16, "expmonth") - member __.cardnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "cardnumber") member __.cardtype = RequiredColumn(reader, getOrdinal, reader.GetString, "cardtype") + member __.cardnumber = RequiredColumn(reader, getOrdinal, reader.GetString, "cardnumber") + member __.expmonth = RequiredColumn(reader, getOrdinal, reader.GetInt16, "expmonth") + member __.expyear = RequiredColumn(reader, getOrdinal, reader.GetInt16, "expyear") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - creditcardid = __.creditcardid.Read() - expyear = __.expyear.Read() - expmonth = __.expmonth.Read() + { creditcardid = __.creditcardid.Read() + cardtype = __.cardtype.Read() cardnumber = __.cardnumber.Read() - cardtype = __.cardtype.Read() } + expmonth = __.expmonth.Read() + expyear = __.expyear.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.creditcardid.IsNull() then None else Some(__.Read()) [] type currency = - { name: string - modifieddate: System.DateTime - currencycode: string } + { currencycode: string + name: string + modifieddate: System.DateTime } type currencyReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.currencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "currencycode") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.currencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "currencycode") member __.Read() = - { name = __.name.Read() - modifieddate = __.modifieddate.Read() - currencycode = __.currencycode.Read() } + { currencycode = __.currencycode.Read() + name = __.name.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.currencycode.IsNull() then None else Some(__.Read()) [] type currencyrate = - { currencyratedate: System.DateTime - tocurrencycode: string + { currencyrateid: int + currencyratedate: System.DateTime fromcurrencycode: string - modifieddate: System.DateTime + tocurrencycode: string averagerate: decimal - currencyrateid: int - endofdayrate: decimal } + endofdayrate: decimal + modifieddate: System.DateTime } type currencyrateReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.currencyrateid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "currencyrateid") member __.currencyratedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "currencyratedate") - member __.tocurrencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "tocurrencycode") member __.fromcurrencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "fromcurrencycode") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.tocurrencycode = RequiredColumn(reader, getOrdinal, reader.GetString, "tocurrencycode") member __.averagerate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "averagerate") - member __.currencyrateid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "currencyrateid") member __.endofdayrate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "endofdayrate") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { currencyratedate = __.currencyratedate.Read() - tocurrencycode = __.tocurrencycode.Read() + { currencyrateid = __.currencyrateid.Read() + currencyratedate = __.currencyratedate.Read() fromcurrencycode = __.fromcurrencycode.Read() - modifieddate = __.modifieddate.Read() + tocurrencycode = __.tocurrencycode.Read() averagerate = __.averagerate.Read() - currencyrateid = __.currencyrateid.Read() - endofdayrate = __.endofdayrate.Read() } + endofdayrate = __.endofdayrate.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.currencyrateid.IsNull() then None else Some(__.Read()) [] type customer = - { modifieddate: System.DateTime - territoryid: Option - storeid: Option + { customerid: int personid: Option + storeid: Option + territoryid: Option rowguid: System.Guid - customerid: int } + modifieddate: System.DateTime } type customerReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.territoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "territoryid") - member __.storeid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "storeid") + member __.customerid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "customerid") member __.personid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "personid") + member __.storeid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "storeid") + member __.territoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.customerid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "customerid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { modifieddate = __.modifieddate.Read() - territoryid = __.territoryid.Read() - storeid = __.storeid.Read() + { customerid = __.customerid.Read() personid = __.personid.Read() + storeid = __.storeid.Read() + territoryid = __.territoryid.Read() rowguid = __.rowguid.Read() - customerid = __.customerid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.customerid.IsNull() then None else Some(__.Read()) [] type personcreditcard = - { creditcardid: int - modifieddate: System.DateTime - businessentityid: int } + { businessentityid: int + creditcardid: int + modifieddate: System.DateTime } type personcreditcardReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.creditcardid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "creditcardid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.Read() = - { creditcardid = __.creditcardid.Read() - modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() } + { businessentityid = __.businessentityid.Read() + creditcardid = __.creditcardid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.creditcardid.IsNull() then None else Some(__.Read()) + if __.businessentityid.IsNull() then None else Some(__.Read()) [] type salesorderdetail = - { specialofferid: int - modifieddate: System.DateTime - productid: int - salesorderid: int - rowguid: System.Guid - unitpricediscount: decimal - unitprice: decimal + { salesorderid: int salesorderdetailid: int + carriertrackingnumber: Option orderqty: int16 - carriertrackingnumber: Option } + productid: int + specialofferid: int + unitprice: decimal + unitpricediscount: decimal + rowguid: System.Guid + modifieddate: System.DateTime } type salesorderdetailReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.specialofferid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "specialofferid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.salesorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salesorderid") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.unitpricediscount = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitpricediscount") - member __.unitprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitprice") member __.salesorderdetailid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salesorderdetailid") - member __.orderqty = RequiredColumn(reader, getOrdinal, reader.GetInt16, "orderqty") member __.carriertrackingnumber = OptionalColumn(reader, getOrdinal, reader.GetString, "carriertrackingnumber") + member __.orderqty = RequiredColumn(reader, getOrdinal, reader.GetInt16, "orderqty") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.specialofferid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "specialofferid") + member __.unitprice = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitprice") + member __.unitpricediscount = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "unitpricediscount") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { specialofferid = __.specialofferid.Read() - modifieddate = __.modifieddate.Read() - productid = __.productid.Read() - salesorderid = __.salesorderid.Read() - rowguid = __.rowguid.Read() - unitpricediscount = __.unitpricediscount.Read() - unitprice = __.unitprice.Read() + { salesorderid = __.salesorderid.Read() salesorderdetailid = __.salesorderdetailid.Read() + carriertrackingnumber = __.carriertrackingnumber.Read() orderqty = __.orderqty.Read() - carriertrackingnumber = __.carriertrackingnumber.Read() } + productid = __.productid.Read() + specialofferid = __.specialofferid.Read() + unitprice = __.unitprice.Read() + unitpricediscount = __.unitpricediscount.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.salesorderid.IsNull() then None else Some(__.Read()) [] type salesorderheader = - { creditcardapprovalcode: Option + { salesorderid: int revisionnumber: int16 - territoryid: Option - currencyrateid: Option - shipmethodid: int - duedate: System.DateTime orderdate: System.DateTime - billtoaddressid: int - accountnumber: Option - comment: Option - totaldue: Option - onlineorderflag: bool - subtotal: decimal - salespersonid: Option - customerid: int + duedate: System.DateTime shipdate: Option - salesorderid: int - freight: decimal + status: int16 + onlineorderflag: bool purchaseordernumber: Option - rowguid: System.Guid - modifieddate: System.DateTime + accountnumber: Option + customerid: int + salespersonid: Option + territoryid: Option + billtoaddressid: int + shiptoaddressid: int + shipmethodid: int creditcardid: Option + creditcardapprovalcode: Option + currencyrateid: Option + subtotal: decimal taxamt: decimal - shiptoaddressid: int - status: int16 } + freight: decimal + totaldue: Option + comment: Option + rowguid: System.Guid + modifieddate: System.DateTime } type salesorderheaderReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.salesorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salesorderid") + member __.revisionnumber = RequiredColumn(reader, getOrdinal, reader.GetInt16, "revisionnumber") + member __.orderdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "orderdate") + member __.duedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "duedate") + member __.shipdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "shipdate") + member __.status = RequiredColumn(reader, getOrdinal, reader.GetInt16, "status") + member __.onlineorderflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "onlineorderflag") + member __.purchaseordernumber = OptionalColumn(reader, getOrdinal, reader.GetString, "purchaseordernumber") + member __.accountnumber = OptionalColumn(reader, getOrdinal, reader.GetString, "accountnumber") + member __.customerid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "customerid") + member __.salespersonid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "salespersonid") + member __.territoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "territoryid") + member __.billtoaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "billtoaddressid") + member __.shiptoaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shiptoaddressid") + member __.shipmethodid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shipmethodid") + member __.creditcardid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "creditcardid") member __.creditcardapprovalcode = OptionalColumn(reader, getOrdinal, reader.GetString, "creditcardapprovalcode") - member __.revisionnumber = RequiredColumn(reader, getOrdinal, reader.GetInt16, "revisionnumber") - member __.territoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.currencyrateid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "currencyrateid") - member __.shipmethodid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shipmethodid") - member __.duedate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "duedate") - member __.orderdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "orderdate") - member __.billtoaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "billtoaddressid") - member __.accountnumber = OptionalColumn(reader, getOrdinal, reader.GetString, "accountnumber") - member __.comment = OptionalColumn(reader, getOrdinal, reader.GetString, "comment") - member __.totaldue = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "totaldue") - member __.onlineorderflag = RequiredColumn(reader, getOrdinal, reader.GetBoolean, "onlineorderflag") member __.subtotal = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "subtotal") - member __.salespersonid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "salespersonid") - member __.customerid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "customerid") - member __.shipdate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "shipdate") - member __.salesorderid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salesorderid") + member __.taxamt = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxamt") member __.freight = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "freight") - member __.purchaseordernumber = OptionalColumn(reader, getOrdinal, reader.GetString, "purchaseordernumber") + member __.totaldue = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "totaldue") + member __.comment = OptionalColumn(reader, getOrdinal, reader.GetString, "comment") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.creditcardid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "creditcardid") - member __.taxamt = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxamt") - member __.shiptoaddressid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shiptoaddressid") - member __.status = RequiredColumn(reader, getOrdinal, reader.GetInt16, "status") member __.Read() = - { creditcardapprovalcode = __.creditcardapprovalcode.Read() + { salesorderid = __.salesorderid.Read() revisionnumber = __.revisionnumber.Read() - territoryid = __.territoryid.Read() - currencyrateid = __.currencyrateid.Read() - shipmethodid = __.shipmethodid.Read() - duedate = __.duedate.Read() orderdate = __.orderdate.Read() - billtoaddressid = __.billtoaddressid.Read() - accountnumber = __.accountnumber.Read() - comment = __.comment.Read() - totaldue = __.totaldue.Read() - onlineorderflag = __.onlineorderflag.Read() - subtotal = __.subtotal.Read() - salespersonid = __.salespersonid.Read() - customerid = __.customerid.Read() + duedate = __.duedate.Read() shipdate = __.shipdate.Read() - salesorderid = __.salesorderid.Read() - freight = __.freight.Read() + status = __.status.Read() + onlineorderflag = __.onlineorderflag.Read() purchaseordernumber = __.purchaseordernumber.Read() - rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() + accountnumber = __.accountnumber.Read() + customerid = __.customerid.Read() + salespersonid = __.salespersonid.Read() + territoryid = __.territoryid.Read() + billtoaddressid = __.billtoaddressid.Read() + shiptoaddressid = __.shiptoaddressid.Read() + shipmethodid = __.shipmethodid.Read() creditcardid = __.creditcardid.Read() + creditcardapprovalcode = __.creditcardapprovalcode.Read() + currencyrateid = __.currencyrateid.Read() + subtotal = __.subtotal.Read() taxamt = __.taxamt.Read() - shiptoaddressid = __.shiptoaddressid.Read() - status = __.status.Read() } + freight = __.freight.Read() + totaldue = __.totaldue.Read() + comment = __.comment.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.salesorderid.IsNull() then None else Some(__.Read()) @@ -1721,150 +1742,150 @@ module sales = [] type salesperson = - { rowguid: System.Guid - saleslastyear: decimal + { businessentityid: int territoryid: Option salesquota: Option bonus: decimal - salesytd: decimal commissionpct: decimal - modifieddate: System.DateTime - businessentityid: int } + salesytd: decimal + saleslastyear: decimal + rowguid: System.Guid + modifieddate: System.DateTime } type salespersonReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.saleslastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "saleslastyear") + member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.territoryid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.salesquota = OptionalColumn(reader, getOrdinal, reader.GetDecimal, "salesquota") member __.bonus = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "bonus") - member __.salesytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesytd") member __.commissionpct = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "commissionpct") + member __.salesytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesytd") + member __.saleslastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "saleslastyear") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") member __.Read() = - { rowguid = __.rowguid.Read() - saleslastyear = __.saleslastyear.Read() + { businessentityid = __.businessentityid.Read() territoryid = __.territoryid.Read() salesquota = __.salesquota.Read() bonus = __.bonus.Read() - salesytd = __.salesytd.Read() commissionpct = __.commissionpct.Read() - modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() } + salesytd = __.salesytd.Read() + saleslastyear = __.saleslastyear.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type salespersonquotahistory = - { rowguid: System.Guid - salesquota: decimal + { businessentityid: int quotadate: System.DateTime - businessentityid: int + salesquota: decimal + rowguid: System.Guid modifieddate: System.DateTime } type salespersonquotahistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.salesquota = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesquota") - member __.quotadate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "quotadate") member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.quotadate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "quotadate") + member __.salesquota = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesquota") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { rowguid = __.rowguid.Read() - salesquota = __.salesquota.Read() + { businessentityid = __.businessentityid.Read() quotadate = __.quotadate.Read() - businessentityid = __.businessentityid.Read() + salesquota = __.salesquota.Read() + rowguid = __.rowguid.Read() modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = - if __.quotadate.IsNull() then None else Some(__.Read()) + if __.businessentityid.IsNull() then None else Some(__.Read()) [] type salesreason = { salesreasonid: int name: string - modifieddate: System.DateTime - reasontype: string } + reasontype: string + modifieddate: System.DateTime } type salesreasonReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.salesreasonid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salesreasonid") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.reasontype = RequiredColumn(reader, getOrdinal, reader.GetString, "reasontype") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { salesreasonid = __.salesreasonid.Read() name = __.name.Read() - modifieddate = __.modifieddate.Read() - reasontype = __.reasontype.Read() } + reasontype = __.reasontype.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.salesreasonid.IsNull() then None else Some(__.Read()) [] type salestaxrate = - { stateprovinceid: int - taxrate: decimal + { salestaxrateid: int + stateprovinceid: int taxtype: int16 - modifieddate: System.DateTime + taxrate: decimal name: string - salestaxrateid: int - rowguid: System.Guid } + rowguid: System.Guid + modifieddate: System.DateTime } type salestaxrateReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.salestaxrateid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salestaxrateid") member __.stateprovinceid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "stateprovinceid") - member __.taxrate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxrate") member __.taxtype = RequiredColumn(reader, getOrdinal, reader.GetInt16, "taxtype") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.taxrate = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "taxrate") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.salestaxrateid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "salestaxrateid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { stateprovinceid = __.stateprovinceid.Read() - taxrate = __.taxrate.Read() + { salestaxrateid = __.salestaxrateid.Read() + stateprovinceid = __.stateprovinceid.Read() taxtype = __.taxtype.Read() - modifieddate = __.modifieddate.Read() + taxrate = __.taxrate.Read() name = __.name.Read() - salestaxrateid = __.salestaxrateid.Read() - rowguid = __.rowguid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.salestaxrateid.IsNull() then None else Some(__.Read()) [] type salesterritory = - { saleslastyear: decimal + { territoryid: int + name: string + countryregioncode: string + group: string salesytd: decimal - territoryid: int - rowguid: System.Guid - modifieddate: System.DateTime + saleslastyear: decimal costytd: decimal costlastyear: decimal - name: string - group: string - countryregioncode: string } + rowguid: System.Guid + modifieddate: System.DateTime } type salesterritoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.saleslastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "saleslastyear") - member __.salesytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesytd") member __.territoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "territoryid") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.costytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "costytd") - member __.costlastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "costlastyear") member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.group = RequiredColumn(reader, getOrdinal, reader.GetString, "group") member __.countryregioncode = RequiredColumn(reader, getOrdinal, reader.GetString, "countryregioncode") + member __.group = RequiredColumn(reader, getOrdinal, reader.GetString, "group") + member __.salesytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "salesytd") + member __.saleslastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "saleslastyear") + member __.costytd = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "costytd") + member __.costlastyear = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "costlastyear") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { saleslastyear = __.saleslastyear.Read() + { territoryid = __.territoryid.Read() + name = __.name.Read() + countryregioncode = __.countryregioncode.Read() + group = __.group.Read() salesytd = __.salesytd.Read() - territoryid = __.territoryid.Read() - rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() + saleslastyear = __.saleslastyear.Read() costytd = __.costytd.Read() costlastyear = __.costlastyear.Read() - name = __.name.Read() - group = __.group.Read() - countryregioncode = __.countryregioncode.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.territoryid.IsNull() then None else Some(__.Read()) @@ -1872,95 +1893,95 @@ module sales = [] type salesterritoryhistory = { businessentityid: int - rowguid: System.Guid - modifieddate: System.DateTime + territoryid: int startdate: System.DateTime enddate: Option - territoryid: int } + rowguid: System.Guid + modifieddate: System.DateTime } type salesterritoryhistoryReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") + member __.territoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "territoryid") member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.enddate = OptionalColumn(reader, getOrdinal, reader.GetDateTime, "enddate") - member __.territoryid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "territoryid") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = { businessentityid = __.businessentityid.Read() - rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() + territoryid = __.territoryid.Read() startdate = __.startdate.Read() enddate = __.enddate.Read() - territoryid = __.territoryid.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) [] type shoppingcartitem = - { datecreated: System.DateTime - shoppingcartitemid: int - modifieddate: System.DateTime + { shoppingcartitemid: int shoppingcartid: string quantity: int - productid: int } + productid: int + datecreated: System.DateTime + modifieddate: System.DateTime } type shoppingcartitemReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.datecreated = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "datecreated") member __.shoppingcartitemid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "shoppingcartitemid") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.shoppingcartid = RequiredColumn(reader, getOrdinal, reader.GetString, "shoppingcartid") member __.quantity = RequiredColumn(reader, getOrdinal, reader.GetInt32, "quantity") member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") + member __.datecreated = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "datecreated") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { datecreated = __.datecreated.Read() - shoppingcartitemid = __.shoppingcartitemid.Read() - modifieddate = __.modifieddate.Read() + { shoppingcartitemid = __.shoppingcartitemid.Read() shoppingcartid = __.shoppingcartid.Read() quantity = __.quantity.Read() - productid = __.productid.Read() } + productid = __.productid.Read() + datecreated = __.datecreated.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.shoppingcartitemid.IsNull() then None else Some(__.Read()) [] type specialoffer = - { discountpct: decimal - ``type``: string + { specialofferid: int description: string - minqty: int + discountpct: decimal + ``type``: string + category: string + startdate: System.DateTime enddate: System.DateTime - rowguid: System.Guid + minqty: int maxqty: Option - specialofferid: int - modifieddate: System.DateTime - category: string - startdate: System.DateTime } + rowguid: System.Guid + modifieddate: System.DateTime } type specialofferReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = + member __.specialofferid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "specialofferid") + member __.description = RequiredColumn(reader, getOrdinal, reader.GetString, "description") member __.discountpct = RequiredColumn(reader, getOrdinal, reader.GetDecimal, "discountpct") member __.``type`` = RequiredColumn(reader, getOrdinal, reader.GetString, "type") - member __.description = RequiredColumn(reader, getOrdinal, reader.GetString, "description") - member __.minqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "minqty") + member __.category = RequiredColumn(reader, getOrdinal, reader.GetString, "category") + member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.enddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "enddate") - member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.minqty = RequiredColumn(reader, getOrdinal, reader.GetInt32, "minqty") member __.maxqty = OptionalColumn(reader, getOrdinal, reader.GetInt32, "maxqty") - member __.specialofferid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "specialofferid") + member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.category = RequiredColumn(reader, getOrdinal, reader.GetString, "category") - member __.startdate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "startdate") member __.Read() = - { discountpct = __.discountpct.Read() - ``type`` = __.``type``.Read() + { specialofferid = __.specialofferid.Read() description = __.description.Read() - minqty = __.minqty.Read() + discountpct = __.discountpct.Read() + ``type`` = __.``type``.Read() + category = __.category.Read() + startdate = __.startdate.Read() enddate = __.enddate.Read() - rowguid = __.rowguid.Read() + minqty = __.minqty.Read() maxqty = __.maxqty.Read() - specialofferid = __.specialofferid.Read() - modifieddate = __.modifieddate.Read() - category = __.category.Read() - startdate = __.startdate.Read() } + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.specialofferid.IsNull() then None else Some(__.Read()) @@ -1968,47 +1989,47 @@ module sales = [] type specialofferproduct = { specialofferid: int + productid: int rowguid: System.Guid - modifieddate: System.DateTime - productid: int } + modifieddate: System.DateTime } type specialofferproductReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = member __.specialofferid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "specialofferid") + member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") - member __.productid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "productid") member __.Read() = { specialofferid = __.specialofferid.Read() + productid = __.productid.Read() rowguid = __.rowguid.Read() - modifieddate = __.modifieddate.Read() - productid = __.productid.Read() } + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.specialofferid.IsNull() then None else Some(__.Read()) [] type store = - { demographics: Option - salespersonid: Option + { businessentityid: int name: string - modifieddate: System.DateTime - businessentityid: int - rowguid: System.Guid } + salespersonid: Option + demographics: Option + rowguid: System.Guid + modifieddate: System.DateTime } type storeReader(reader: Npgsql.NpgsqlDataReader, getOrdinal) = - member __.demographics = OptionalColumn(reader, getOrdinal, reader.GetString, "demographics") - member __.salespersonid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "salespersonid") - member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") - member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.businessentityid = RequiredColumn(reader, getOrdinal, reader.GetInt32, "businessentityid") + member __.name = RequiredColumn(reader, getOrdinal, reader.GetString, "name") + member __.salespersonid = OptionalColumn(reader, getOrdinal, reader.GetInt32, "salespersonid") + member __.demographics = OptionalColumn(reader, getOrdinal, reader.GetString, "demographics") member __.rowguid = RequiredColumn(reader, getOrdinal, reader.GetGuid, "rowguid") + member __.modifieddate = RequiredColumn(reader, getOrdinal, reader.GetDateTime, "modifieddate") member __.Read() = - { demographics = __.demographics.Read() - salespersonid = __.salespersonid.Read() + { businessentityid = __.businessentityid.Read() name = __.name.Read() - modifieddate = __.modifieddate.Read() - businessentityid = __.businessentityid.Read() - rowguid = __.rowguid.Read() } + salespersonid = __.salespersonid.Read() + demographics = __.demographics.Read() + rowguid = __.rowguid.Read() + modifieddate = __.modifieddate.Read() } member __.ReadIfNotNull() = if __.businessentityid.IsNull() then None else Some(__.Read()) @@ -2070,6 +2091,7 @@ type HydraReader(reader: Npgsql.NpgsqlDataReader) = let lazyproductionunitmeasure = lazy (production.unitmeasureReader (reader, buildGetOrdinal 3)) let lazyproductionworkorder = lazy (production.workorderReader (reader, buildGetOrdinal 9)) let lazyproductionworkorderrouting = lazy (production.workorderroutingReader (reader, buildGetOrdinal 12)) + let lazyproviderdbtypetesttest = lazy (providerdbtypetest.testReader (reader, buildGetOrdinal 3)) let lazypurchasingproductvendor = lazy (purchasing.productvendorReader (reader, buildGetOrdinal 11)) let lazypurchasingpurchaseorderdetail = lazy (purchasing.purchaseorderdetailReader (reader, buildGetOrdinal 9)) let lazypurchasingpurchaseorderheader = lazy (purchasing.purchaseorderheaderReader (reader, buildGetOrdinal 12)) @@ -2138,6 +2160,7 @@ type HydraReader(reader: Npgsql.NpgsqlDataReader) = member __.``production.unitmeasure`` = lazyproductionunitmeasure.Value member __.``production.workorder`` = lazyproductionworkorder.Value member __.``production.workorderrouting`` = lazyproductionworkorderrouting.Value + member __.``providerdbtypetest.test`` = lazyproviderdbtypetesttest.Value member __.``purchasing.productvendor`` = lazypurchasingproductvendor.Value member __.``purchasing.purchaseorderdetail`` = lazypurchasingpurchaseorderdetail.Value member __.``purchasing.purchaseorderheader`` = lazypurchasingpurchaseorderheader.Value @@ -2253,6 +2276,8 @@ type HydraReader(reader: Npgsql.NpgsqlDataReader) = | "production.workorder", true -> __.``production.workorder``.ReadIfNotNull >> box | "production.workorderrouting", false -> __.``production.workorderrouting``.Read >> box | "production.workorderrouting", true -> __.``production.workorderrouting``.ReadIfNotNull >> box + | "providerdbtypetest.test", false -> __.``providerdbtypetest.test``.Read >> box + | "providerdbtypetest.test", true -> __.``providerdbtypetest.test``.ReadIfNotNull >> box | "purchasing.productvendor", false -> __.``purchasing.productvendor``.Read >> box | "purchasing.productvendor", true -> __.``purchasing.productvendor``.ReadIfNotNull >> box | "purchasing.purchaseorderdetail", false -> __.``purchasing.purchaseorderdetail``.Read >> box diff --git a/src/Tests/Npgsql/Generation.fs b/src/Tests/Npgsql/Generation.fs index cfb4a071..157d7fbd 100644 --- a/src/Tests/Npgsql/Generation.fs +++ b/src/Tests/Npgsql/Generation.fs @@ -74,8 +74,16 @@ let tests = let pks = allColumns |> List.filter (fun c -> c.IsPK) - Expect.equal schema.Tables.Length 68 "" + Expect.equal schema.Tables.Length 69 "" Expect.isTrue (pks.Length > schema.Tables.Length) "Expected at least one pk per table" Expect.isTrue (pks.Length < allColumns.Length) "Every column should not be a PK" } + + test "Code Should Have ProviderDbTypeAttribute With Json" { + cfg |> inCode "[]" + } + + test "Code Should Have ProviderDbTypeAttribute With Jsonb" { + cfg |> inCode "[]" + } ] \ No newline at end of file diff --git a/src/Tests/Npgsql/QueryIntegrationTests.fs b/src/Tests/Npgsql/QueryIntegrationTests.fs index 955ff3a4..a7384f23 100644 --- a/src/Tests/Npgsql/QueryIntegrationTests.fs +++ b/src/Tests/Npgsql/QueryIntegrationTests.fs @@ -1,6 +1,7 @@ module Npgsql.QueryIntegrationTests open Expecto +open Npgsql.AdventureWorks.person open SqlHydra.Query open DB open Npgsql.AdventureWorks @@ -22,6 +23,7 @@ let subCategoryTable = table |> inSchema let categoryTable = table |> inSchema (nameof production) let currencyTable = table |> inSchema (nameof sales) let productReviewTable = table |> inSchema (nameof production) +let providerDbTestTable = table |> inSchema (nameof providerdbtypetest) [] let tests = @@ -452,4 +454,71 @@ let tests = ctx.RollbackTransaction() } + + testTask "Insert, Update and Read npgsql provider specific db fields" { + use ctx = openContext () + + let expectJsonEqual (dbValue: string) = Expect.equal (dbValue.Replace(" ", "")) + + let getRowById id = + select { + for e in providerDbTestTable do + select e + where (e.id = id) + } |> ctx.ReadAsync HydraReader.Read + + // Simple insert of one entity + let jsonValue = """{"name":"test"}""" + let entity': providerdbtypetest.test = + { + id = 0 + json_field = jsonValue + jsonb_field = jsonValue + } + + let! insertedRowId = + insert { + for e in providerDbTestTable do + entity entity' + getId e.id + } + |> ctx.InsertAsync + + let! selectedRows = getRowById insertedRowId + + Expect.wantSome (selectedRows |> Seq.tryHead) "Select returned empty set" + |> fun (row: providerdbtypetest.test) -> + expectJsonEqual row.json_field jsonValue "Json field after insert doesn't match" + expectJsonEqual row.jsonb_field jsonValue "Jsonb field after insert doesn't match" + + // Simple update of one entity + let updatedJsonValue = """{"name":"test_2"}""" + let! updatedRows = + update { + for e in providerDbTestTable do + set e.json_field updatedJsonValue + set e.jsonb_field updatedJsonValue + where (e.id = insertedRowId) + } + |> ctx.UpdateAsync + + Expect.equal updatedRows 1 "Expected 1 row to be updated" + + let! selectedRowsAfterUpdate = getRowById insertedRowId + + Expect.wantSome (selectedRowsAfterUpdate |> Seq.tryHead) "Select returned empty set" + |> fun (row: providerdbtypetest.test) -> + expectJsonEqual row.json_field updatedJsonValue "Json field after update doesn't match" + expectJsonEqual row.jsonb_field updatedJsonValue "Jsonb field after update doesn't match" + + // Insert of multiple entities + let! insertedNumberOfRows = + insert { + for e in providerDbTestTable do + entities [entity'; entity'] + } + |> ctx.InsertAsync + + Expect.equal insertedNumberOfRows 2 "Failed insert multiple entities" + } ] \ No newline at end of file diff --git a/src/Tests/Npgsql/QueryUnitTests.fs b/src/Tests/Npgsql/QueryUnitTests.fs index 6d57099a..96bd438f 100644 --- a/src/Tests/Npgsql/QueryUnitTests.fs +++ b/src/Tests/Npgsql/QueryUnitTests.fs @@ -350,7 +350,7 @@ let tests = let sql = query.ToKataQuery() |> toSql Expect.equal sql - "INSERT INTO \"sales\".\"customer\" (\"modifieddate\", \"territoryid\", \"storeid\", \"personid\", \"rowguid\", \"customerid\") VALUES (@p0, @p1, @p2, @p3, @p4, @p5)" + "INSERT INTO \"sales\".\"customer\" (\"customerid\", \"personid\", \"storeid\", \"territoryid\", \"rowguid\", \"modifieddate\") VALUES (@p0, @p1, @p2, @p3, @p4, @p5)" "" } diff --git a/src/Tests/UnitTests/TableFilters.fs b/src/Tests/UnitTests/TableFilters.fs index ee4640db..4ce9c1cd 100644 --- a/src/Tests/UnitTests/TableFilters.fs +++ b/src/Tests/UnitTests/TableFilters.fs @@ -1,10 +1,8 @@ module UnitTests.TableFilters open Expecto -open System -open SqlHydra +open SqlHydra.Filter open SqlHydra.Domain -open System.Globalization [] let tests =