//---------------------------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated by T4Model template for T4 (https://github.com/linq2db/linq2db).
//    Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//---------------------------------------------------------------------------------------------------

#pragma warning disable 1573, 1591
#nullable enable

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Net;
using System.Net.NetworkInformation;
using System.Reflection;

using LinqToDB;
using LinqToDB.Common;
using LinqToDB.Configuration;
using LinqToDB.Data;
using LinqToDB.Mapping;

using NpgsqlTypes;

namespace PostreSQL11DataContext
{
	public partial class TestdataDB : LinqToDB.Data.DataConnection
	{
		public ITable<_testsamename>                  _testsamename             { get { return this.GetTable<_testsamename>(); } }
		public ITable<AllType>                        AllTypes                  { get { return this.GetTable<AllType>(); } }
		public ITable<Child>                          Children                  { get { return this.GetTable<Child>(); } }
		public ITable<CollatedTable>                  CollatedTables            { get { return this.GetTable<CollatedTable>(); } }
		public ITable<Doctor>                         Doctors                   { get { return this.GetTable<Doctor>(); } }
		public ITable<Entity>                         Entities                  { get { return this.GetTable<Entity>(); } }
		public ITable<GrandChild>                     GrandChildren             { get { return this.GetTable<GrandChild>(); } }
		public ITable<InheritanceChild>               InheritanceChildren       { get { return this.GetTable<InheritanceChild>(); } }
		public ITable<InheritanceParent>              InheritanceParents        { get { return this.GetTable<InheritanceParent>(); } }
		/// <summary>
		/// This is the Issue2023 matview
		/// </summary>
		public ITable<Issue2023>                      Issue2023                 { get { return this.GetTable<Issue2023>(); } }
		public ITable<LinqDataType>                   LinqDataTypes             { get { return this.GetTable<LinqDataType>(); } }
		public ITable<Parent>                         Parents                   { get { return this.GetTable<Parent>(); } }
		public ITable<Patient>                        Patients                  { get { return this.GetTable<Patient>(); } }
		/// <summary>
		/// This is the Person table
		/// </summary>
		public ITable<Person>                         People                    { get { return this.GetTable<Person>(); } }
		public ITable<SameName>                       SameNames                 { get { return this.GetTable<SameName>(); } }
		public ITable<SameName1>                      SameName1                 { get { return this.GetTable<SameName1>(); } }
		public ITable<SameName2>                      SameName2                 { get { return this.GetTable<SameName2>(); } }
		public ITable<SequenceCustomNamingTest>       SequenceCustomNamingTests { get { return this.GetTable<SequenceCustomNamingTest>(); } }
		public ITable<SequenceTest1>                  SequenceTest1             { get { return this.GetTable<SequenceTest1>(); } }
		public ITable<SequenceTest2>                  SequenceTest2             { get { return this.GetTable<SequenceTest2>(); } }
		public ITable<SequenceTest3>                  SequenceTest3             { get { return this.GetTable<SequenceTest3>(); } }
		public ITable<TestIdentity>                   TestIdentities            { get { return this.GetTable<TestIdentity>(); } }
		public ITable<TestMerge1>                     TestMerge1                { get { return this.GetTable<TestMerge1>(); } }
		public ITable<TestMerge2>                     TestMerge2                { get { return this.GetTable<TestMerge2>(); } }
		public ITable<TestMergeIdentity>              TestMergeIdentities       { get { return this.GetTable<TestMergeIdentity>(); } }
		public ITable<test_schema_Testsamename>       Testsamenames             { get { return this.GetTable<test_schema_Testsamename>(); } }
		public ITable<test_schema_TestSchemaIdentity> TestSchemaIdentities      { get { return this.GetTable<test_schema_TestSchemaIdentity>(); } }
		public ITable<test_schema_Testserialidentity> Testserialidentities      { get { return this.GetTable<test_schema_Testserialidentity>(); } }

		partial void InitMappingSchema()
		{
			MappingSchema.SetConvertExpression<object?[], TestFunctionParametersResult>(tuple => new TestFunctionParametersResult() { param2 = (int?)tuple[0], param3 = (int?)tuple[1] });
		}

		public TestdataDB()
		{
			InitDataContext();
			InitMappingSchema();
		}

		public TestdataDB(string configuration)
			: base(configuration)
		{
			InitDataContext();
			InitMappingSchema();
		}

		public TestdataDB(DataOptions options)
			: base(options)
		{
			InitDataContext();
			InitMappingSchema();
		}

		public TestdataDB(DataOptions<TestdataDB> options)
			: base(options.Options)
		{
			InitDataContext();
			InitMappingSchema();
		}

		partial void InitDataContext  ();
		partial void InitMappingSchema();

		#region Table Functions

		#region GetParentByID

		[Sql.TableFunction(Schema="public", Name="\"GetParentByID\"")]
		public ITable<Parent> GetParentByID(int? id)
		{
			return this.GetTable<Parent>(this, (MethodInfo)MethodBase.GetCurrentMethod()!,
				id);
		}

		#endregion

		#region TestTableFunction1

		[Sql.TableFunction(Schema="public", Name="\"TestTableFunction1\"")]
		public ITable<TestTableFunction1Result> TestTableFunction1(int? param1, int? param2)
		{
			return this.GetTable<TestTableFunction1Result>(this, (MethodInfo)MethodBase.GetCurrentMethod()!,
				param1,
				param2);
		}

		public partial class TestTableFunction1Result
		{
			public int? param3 { get; set; }
			public int? param4 { get; set; }
		}

		#endregion

		#region TestTableFunction

		[Sql.TableFunction(Schema="public", Name="\"TestTableFunction\"")]
		public ITable<TestTableFunctionResult> TestTableFunction(int? param1)
		{
			return this.GetTable<TestTableFunctionResult>(this, (MethodInfo)MethodBase.GetCurrentMethod()!,
				param1);
		}

		public partial class TestTableFunctionResult
		{
			public int? param2 { get; set; }
		}

		#endregion

		#region TestTableFunctionSchema

		[Sql.TableFunction(Schema="public", Name="\"TestTableFunctionSchema\"")]
		public ITable<TestTableFunctionSchemaResult> TestTableFunctionSchema()
		{
			return this.GetTable<TestTableFunctionSchemaResult>(this, (MethodInfo)MethodBase.GetCurrentMethod()!);
		}

		public partial class TestTableFunctionSchemaResult
		{
			public int?                        ID                  { get; set; }
			public long?                       bigintDataType      { get; set; }
			public decimal?                    numericDataType     { get; set; }
			public short?                      smallintDataType    { get; set; }
			public int?                        intDataType         { get; set; }
			public decimal?                    moneyDataType       { get; set; }
			public double?                     doubleDataType      { get; set; }
			public float?                      realDataType        { get; set; }
			public DateTime?                   timestampDataType   { get; set; }
			public DateTimeOffset?             timestampTZDataType { get; set; }
			public DateTime?                   dateDataType        { get; set; }
			public TimeSpan?                   timeDataType        { get; set; }
			public DateTimeOffset?             timeTZDataType      { get; set; }
			public TimeSpan?                   intervalDataType    { get; set; }
			public TimeSpan?                   intervalDataType2   { get; set; }
			public char?                       charDataType        { get; set; }
			public string?                     char20DataType      { get; set; }
			public string?                     varcharDataType     { get; set; }
			public string?                     textDataType        { get; set; }
			public byte[]?                     binaryDataType      { get; set; }
			public Guid?                       uuidDataType        { get; set; }
			public BitArray?                   bitDataType         { get; set; }
			public bool?                       booleanDataType     { get; set; }
			public string?                     colorDataType       { get; set; }
			public NpgsqlPoint?                pointDataType       { get; set; }
			public NpgsqlLSeg?                 lsegDataType        { get; set; }
			public NpgsqlBox?                  boxDataType         { get; set; }
			public NpgsqlPath?                 pathDataType        { get; set; }
			public NpgsqlPolygon?              polygonDataType     { get; set; }
			public NpgsqlCircle?               circleDataType      { get; set; }
			public NpgsqlLine?                 lineDataType        { get; set; }
			public IPAddress?                  inetDataType        { get; set; }
			public ValueTuple<IPAddress, int>? cidrDataType        { get; set; }
			public PhysicalAddress?            macaddrDataType     { get; set; }
			public PhysicalAddress?            macaddr8DataType    { get; set; }
			public string?                     jsonDataType        { get; set; }
			public string?                     jsonbDataType       { get; set; }
			public string?                     xmlDataType         { get; set; }
			public BitArray?                   varBitDataType      { get; set; }
			public string[]?                   strarray            { get; set; }
			public int[]?                      intarray            { get; set; }
			public int[]?                      int2darray          { get; set; }
			public long[]?                     longarray           { get; set; }
			public TimeSpan[]?                 intervalarray       { get; set; }
			public double[]?                   doublearray         { get; set; }
			public decimal[]?                  numericarray        { get; set; }
			public decimal[]?                  decimalarray        { get; set; }
		}

		#endregion

		#endregion
	}

	public partial class TestFunctionParametersResult
	{
		public int? param2 { get; set; }

		public int? param3 { get; set; }
	}

	[Table(Schema="public", Name="testsamename")]
	public partial class _testsamename
	{
		[Column("id", DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int Id { get; set; } // integer
	}

	[Table(Schema="public", Name="AllTypes")]
	public partial class AllType
	{
		[Column(                       DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0), PrimaryKey, Identity] public int                         ID                  { get; set; } // integer
		[Column("bigintDataType",      DataType=LinqToDB.DataType.Int64,          Precision=64, Scale=0), Nullable            ] public long?                       BigintDataType      { get; set; } // bigint
		[Column("numericDataType",     DataType=LinqToDB.DataType.Decimal),                               Nullable            ] public decimal?                    NumericDataType     { get; set; } // numeric
		[Column("smallintDataType",    DataType=LinqToDB.DataType.Int16,          Precision=16, Scale=0), Nullable            ] public short?                      SmallintDataType    { get; set; } // smallint
		[Column("intDataType",         DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0), Nullable            ] public int?                        IntDataType         { get; set; } // integer
		[Column("moneyDataType",       DataType=LinqToDB.DataType.Money),                                 Nullable            ] public decimal?                    MoneyDataType       { get; set; } // money
		[Column("doubleDataType",      DataType=LinqToDB.DataType.Double,         Precision=53),          Nullable            ] public double?                     DoubleDataType      { get; set; } // double precision
		[Column("realDataType",        DataType=LinqToDB.DataType.Single,         Precision=24),          Nullable            ] public float?                      RealDataType        { get; set; } // real
		[Column("timestampDataType",   DataType=LinqToDB.DataType.DateTime2,      Precision=6),           Nullable            ] public DateTime?                   TimestampDataType   { get; set; } // timestamp (6) without time zone
		[Column("timestampTZDataType", DataType=LinqToDB.DataType.DateTimeOffset, Precision=6),           Nullable            ] public DateTimeOffset?             TimestampTZDataType { get; set; } // timestamp (6) with time zone
		[Column("dateDataType",        DataType=LinqToDB.DataType.Date,           Precision=0),           Nullable            ] public DateTime?                   DateDataType        { get; set; } // date
		[Column("timeDataType",        DataType=LinqToDB.DataType.Time,           Precision=6),           Nullable            ] public TimeSpan?                   TimeDataType        { get; set; } // time without time zone
		[Column("timeTZDataType",      DataType=LinqToDB.DataType.Time,           Precision=6),           Nullable            ] public DateTimeOffset?             TimeTZDataType      { get; set; } // time with time zone
		[Column("intervalDataType",    DataType=LinqToDB.DataType.Interval,       Precision=6),           Nullable            ] public TimeSpan?                   IntervalDataType    { get; set; } // interval
		[Column("intervalDataType2",   DataType=LinqToDB.DataType.Interval,       Precision=6),           Nullable            ] public TimeSpan?                   IntervalDataType2   { get; set; } // interval
		[Column("charDataType",        DataType=LinqToDB.DataType.NChar,          Length=1),              Nullable            ] public char?                       CharDataType        { get; set; } // character(1)
		[Column("char20DataType",      DataType=LinqToDB.DataType.NChar,          Length=20),             Nullable            ] public string?                     Char20DataType      { get; set; } // character(20)
		[Column("varcharDataType",     DataType=LinqToDB.DataType.NVarChar,       Length=20),             Nullable            ] public string?                     VarcharDataType     { get; set; } // character varying(20)
		[Column("textDataType",        DataType=LinqToDB.DataType.Text),                                  Nullable            ] public string?                     TextDataType        { get; set; } // text
		[Column("binaryDataType",      DataType=LinqToDB.DataType.Binary),                                Nullable            ] public byte[]?                     BinaryDataType      { get; set; } // bytea
		[Column("uuidDataType",        DataType=LinqToDB.DataType.Guid),                                  Nullable            ] public Guid?                       UuidDataType        { get; set; } // uuid
		[Column("bitDataType",         DataType=LinqToDB.DataType.BitArray,       Length=3),              Nullable            ] public BitArray?                   BitDataType         { get; set; } // bit(3)
		[Column("booleanDataType",     DataType=LinqToDB.DataType.Boolean),                               Nullable            ] public bool?                       BooleanDataType     { get; set; } // boolean
		[Column("colorDataType",       DataType=LinqToDB.DataType.Enum),                                  Nullable            ] public string?                     ColorDataType       { get; set; } // color
		[Column("pointDataType",       DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlPoint?                PointDataType       { get; set; } // point
		[Column("lsegDataType",        DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlLSeg?                 LsegDataType        { get; set; } // lseg
		[Column("boxDataType",         DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlBox?                  BoxDataType         { get; set; } // box
		[Column("pathDataType",        DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlPath?                 PathDataType        { get; set; } // path
		[Column("polygonDataType",     DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlPolygon?              PolygonDataType     { get; set; } // polygon
		[Column("circleDataType",      DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlCircle?               CircleDataType      { get; set; } // circle
		[Column("lineDataType",        DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public NpgsqlLine?                 LineDataType        { get; set; } // line
		[Column("inetDataType",        DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public IPAddress?                  InetDataType        { get; set; } // inet
		[Column("cidrDataType",        DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public ValueTuple<IPAddress, int>? CidrDataType        { get; set; } // cidr
		[Column("macaddrDataType",     DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public PhysicalAddress?            MacaddrDataType     { get; set; } // macaddr
		[Column("macaddr8DataType",    DataType=LinqToDB.DataType.Udt),                                   Nullable            ] public PhysicalAddress?            Macaddr8DataType    { get; set; } // macaddr8
		[Column("jsonDataType",        DataType=LinqToDB.DataType.Json),                                  Nullable            ] public string?                     JsonDataType        { get; set; } // json
		[Column("jsonbDataType",       DataType=LinqToDB.DataType.BinaryJson),                            Nullable            ] public string?                     JsonbDataType       { get; set; } // jsonb
		[Column("xmlDataType",         DataType=LinqToDB.DataType.Xml),                                   Nullable            ] public string?                     XmlDataType         { get; set; } // xml
		[Column("varBitDataType",      DataType=LinqToDB.DataType.BitArray),                              Nullable            ] public BitArray?                   VarBitDataType      { get; set; } // bit varying
		[Column("strarray",            DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public string[]?                   Strarray            { get; set; } // text[]
		[Column("intarray",            DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public int[]?                      Intarray            { get; set; } // integer[]
		[Column("int2darray",          DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public int[][]?                    Int2darray          { get; set; } // integer[][]
		[Column("longarray",           DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public long[]?                     Longarray           { get; set; } // bigint[]
		[Column("intervalarray",       DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public TimeSpan[]?                 Intervalarray       { get; set; } // interval[]
		[Column("doublearray",         DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public double[]?                   Doublearray         { get; set; } // double precision[]
		[Column("numericarray",        DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public decimal[]?                  Numericarray        { get; set; } // numeric[]
		[Column("decimalarray",        DataType=LinqToDB.DataType.Undefined),                             Nullable            ] public decimal[]?                  Decimalarray        { get; set; } // numeric[]
	}

	[Table(Schema="public", Name="Child")]
	public partial class Child
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? ParentID { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? ChildID  { get; set; } // integer
	}

	[Table(Schema="public", Name="CollatedTable")]
	public partial class CollatedTable
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), NotNull] public int    Id              { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=20),             NotNull] public string CaseSensitive   { get; set; } = null!; // character varying(20)
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=20),             NotNull] public string CaseInsensitive { get; set; } = null!; // character varying(20)
	}

	[Table(Schema="public", Name="Doctor")]
	public partial class Doctor
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey, NotNull] public int    PersonID { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),                         NotNull] public string Taxonomy { get; set; } = null!; // character varying(50)

		#region Associations

		/// <summary>
		/// Doctor_PersonID_fkey (public.Person)
		/// </summary>
		[Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=false)]
		public Person Person { get; set; } = null!;

		#endregion
	}

	[Table(Schema="public", Name="entity")]
	public partial class Entity
	{
		[Column("the_name", DataType=LinqToDB.DataType.NVarChar, Length=255), NotNull] public string TheName { get; set; } = null!; // character varying(255)
	}

	[Table(Schema="public", Name="GrandChild")]
	public partial class GrandChild
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? ParentID     { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? ChildID      { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? GrandChildID { get; set; } // integer
	}

	[Table(Schema="public", Name="InheritanceChild")]
	public partial class InheritanceChild
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey,  NotNull] public int     InheritanceChildId  { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0),              NotNull] public int     InheritanceParentId { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0),    Nullable         ] public int?    TypeDiscriminator   { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),                Nullable         ] public string? Name                { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="InheritanceParent")]
	public partial class InheritanceParent
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey,  NotNull] public int     InheritanceParentId { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0),    Nullable         ] public int?    TypeDiscriminator   { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),                Nullable         ] public string? Name                { get; set; } // character varying(50)
	}

	/// <summary>
	/// This is the Issue2023 matview
	/// </summary>
	[Table(Schema="public", Name="Issue2023", IsView=true)]
	public partial class Issue2023
	{
		/// <summary>
		/// This is the Issue2023.PersonID column
		/// </summary>
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0, SkipOnInsert=true, SkipOnUpdate=true), Nullable] public int?    PersonID   { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50, SkipOnInsert=true, SkipOnUpdate=true),             Nullable] public string? FirstName  { get; set; } // character varying(50)
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50, SkipOnInsert=true, SkipOnUpdate=true),             Nullable] public string? LastName   { get; set; } // character varying(50)
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50, SkipOnInsert=true, SkipOnUpdate=true),             Nullable] public string? MiddleName { get; set; } // character varying(50)
		[Column(DataType=LinqToDB.DataType.NChar,    Length=1, SkipOnInsert=true, SkipOnUpdate=true),              Nullable] public char?   Gender     { get; set; } // character(1)
	}

	[Table(Schema="public", Name="LinqDataTypes")]
	public partial class LinqDataType
	{
		[Column(DataType=LinqToDB.DataType.Int32,     Precision=32, Scale=0), Nullable] public int?      ID             { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Decimal,   Precision=10, Scale=4), Nullable] public decimal?  MoneyValue     { get; set; } // numeric(10,4)
		[Column(DataType=LinqToDB.DataType.DateTime2, Precision=6),           Nullable] public DateTime? DateTimeValue  { get; set; } // timestamp (6) without time zone
		[Column(DataType=LinqToDB.DataType.DateTime2, Precision=6),           Nullable] public DateTime? DateTimeValue2 { get; set; } // timestamp (6) without time zone
		[Column(DataType=LinqToDB.DataType.Boolean),                          Nullable] public bool?     BoolValue      { get; set; } // boolean
		[Column(DataType=LinqToDB.DataType.Guid),                             Nullable] public Guid?     GuidValue      { get; set; } // uuid
		[Column(DataType=LinqToDB.DataType.Binary),                           Nullable] public byte[]?   BinaryValue    { get; set; } // bytea
		[Column(DataType=LinqToDB.DataType.Int16,     Precision=16, Scale=0), Nullable] public short?    SmallIntValue  { get; set; } // smallint
		[Column(DataType=LinqToDB.DataType.Int32,     Precision=32, Scale=0), Nullable] public int?      IntValue       { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int64,     Precision=64, Scale=0), Nullable] public long?     BigIntValue    { get; set; } // bigint
		[Column(DataType=LinqToDB.DataType.NVarChar,  Length=50),             Nullable] public string?   StringValue    { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="Parent")]
	public partial class Parent
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? ParentID { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable] public int? Value1   { get; set; } // integer
	}

	[Table(Schema="public", Name="Patient")]
	public partial class Patient
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey, NotNull] public int    PersonID  { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=256),                        NotNull] public string Diagnosis { get; set; } = null!; // character varying(256)

		#region Associations

		/// <summary>
		/// Patient_PersonID_fkey (public.Person)
		/// </summary>
		[Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=false)]
		public Person Person { get; set; } = null!;

		#endregion
	}

	/// <summary>
	/// This is the Person table
	/// </summary>
	[Table(Schema="public", Name="Person")]
	public partial class Person
	{
		/// <summary>
		/// This is the Person.PersonID column
		/// </summary>
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey,  Identity] public int     PersonID   { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),             NotNull              ] public string  FirstName  { get; set; } = null!; // character varying(50)
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),             NotNull              ] public string  LastName   { get; set; } = null!; // character varying(50)
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),                Nullable          ] public string? MiddleName { get; set; } // character varying(50)
		[Column(DataType=LinqToDB.DataType.NChar,    Length=1),              NotNull              ] public char    Gender     { get; set; } // character(1)

		#region Associations

		/// <summary>
		/// Doctor_PersonID_fkey_BackReference (public.Doctor)
		/// </summary>
		[Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=true)]
		public Doctor? DoctorPersonIDfkey { get; set; }

		/// <summary>
		/// Patient_PersonID_fkey_BackReference (public.Patient)
		/// </summary>
		[Association(ThisKey="PersonID", OtherKey="PersonID", CanBeNull=true)]
		public Patient? PatientPersonIDfkey { get; set; }

		#endregion
	}

	[Table(Schema="public", Name="same_name")]
	public partial class SameName
	{
		[Column("id", DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, NotNull] public int Id { get; set; } // integer

		#region Associations

		/// <summary>
		/// same_name_BackReference (public.same_name2)
		/// </summary>
		[Association(ThisKey="Id", OtherKey="SameName", CanBeNull=true)]
		public IEnumerable<SameName2> SameNameBackReferences { get; set; } = null!;

		/// <summary>
		/// same_name_BackReference (public.same_name1)
		/// </summary>
		[Association(ThisKey="Id", OtherKey="SameName", CanBeNull=true)]
		public IEnumerable<SameName1> Samenames { get; set; } = null!;

		#endregion
	}

	[Table(Schema="public", Name="same_name1")]
	public partial class SameName1
	{
		[Column("id",        DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey,  NotNull] public int  Id       { get; set; } // integer
		[Column("same_name", DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0),    Nullable         ] public int? SameName { get; set; } // integer

		#region Associations

		/// <summary>
		/// same_name (public.same_name)
		/// </summary>
		[Association(ThisKey="SameName", OtherKey="Id", CanBeNull=true)]
		public SameName? Samename { get; set; }

		#endregion
	}

	[Table(Schema="public", Name="same_name2")]
	public partial class SameName2
	{
		[Column("id",        DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey,  NotNull] public int  Id       { get; set; } // integer
		[Column("same_name", DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0),    Nullable         ] public int? SameName { get; set; } // integer

		#region Associations

		/// <summary>
		/// same_name (public.same_name)
		/// </summary>
		[Association(ThisKey="SameName", OtherKey="Id", CanBeNull=true)]
		public SameName? Samename { get; set; }

		#endregion
	}

	[Table(Schema="public", Name="SequenceCustomNamingTest")]
	public partial class SequenceCustomNamingTest
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey, Identity] public int     ID    { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),             Nullable            ] public string? Value { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="SequenceTest1")]
	public partial class SequenceTest1
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey,  NotNull] public int     ID    { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),                Nullable         ] public string? Value { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="SequenceTest2")]
	public partial class SequenceTest2
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey, Identity] public int     ID    { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),             Nullable            ] public string? Value { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="SequenceTest3")]
	public partial class SequenceTest3
	{
		[Column(DataType=LinqToDB.DataType.Int32,    Precision=32, Scale=0), PrimaryKey, Identity] public int     ID    { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.NVarChar, Length=50),             Nullable            ] public string? Value { get; set; } // character varying(50)
	}

	[Table(Schema="public", Name="TestIdentity")]
	public partial class TestIdentity
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int ID { get; set; } // integer
	}

	[Table(Schema="public", Name="TestMerge1")]
	public partial class TestMerge1
	{
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),  PrimaryKey,  NotNull] public int             Id              { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field1          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field2          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field3          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field4          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field5          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int64,          Precision=64, Scale=0),     Nullable         ] public long?           FieldInt64      { get; set; } // bigint
		[Column(DataType=LinqToDB.DataType.Boolean),                                   Nullable         ] public bool?           FieldBoolean    { get; set; } // boolean
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldString     { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldNString    { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.NChar,          Length=1),                  Nullable         ] public char?           FieldChar       { get; set; } // character(1)
		[Column(DataType=LinqToDB.DataType.NChar,          Length=1),                  Nullable         ] public char?           FieldNChar      { get; set; } // character(1)
		[Column(DataType=LinqToDB.DataType.Single,         Precision=24),              Nullable         ] public float?          FieldFloat      { get; set; } // real
		[Column(DataType=LinqToDB.DataType.Double,         Precision=53),              Nullable         ] public double?         FieldDouble     { get; set; } // double precision
		[Column(DataType=LinqToDB.DataType.DateTime2,      Precision=6),               Nullable         ] public DateTime?       FieldDateTime   { get; set; } // timestamp (6) without time zone
		[Column(DataType=LinqToDB.DataType.DateTimeOffset, Precision=6),               Nullable         ] public DateTimeOffset? FieldDateTime2  { get; set; } // timestamp (6) with time zone
		[Column(DataType=LinqToDB.DataType.Binary),                                    Nullable         ] public byte[]?         FieldBinary     { get; set; } // bytea
		[Column(DataType=LinqToDB.DataType.Guid),                                      Nullable         ] public Guid?           FieldGuid       { get; set; } // uuid
		[Column(DataType=LinqToDB.DataType.Decimal,        Precision=24, Scale=10),    Nullable         ] public decimal?        FieldDecimal    { get; set; } // numeric(24,10)
		[Column(DataType=LinqToDB.DataType.Date,           Precision=0),               Nullable         ] public DateTime?       FieldDate       { get; set; } // date
		[Column(DataType=LinqToDB.DataType.Time,           Precision=6),               Nullable         ] public TimeSpan?       FieldTime       { get; set; } // time(6) without time zone
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldEnumString { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            FieldEnumNumber { get; set; } // integer
	}

	[Table(Schema="public", Name="TestMerge2")]
	public partial class TestMerge2
	{
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),  PrimaryKey,  NotNull] public int             Id              { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field1          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field2          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field3          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field4          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            Field5          { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int64,          Precision=64, Scale=0),     Nullable         ] public long?           FieldInt64      { get; set; } // bigint
		[Column(DataType=LinqToDB.DataType.Boolean),                                   Nullable         ] public bool?           FieldBoolean    { get; set; } // boolean
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldString     { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldNString    { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.NChar,          Length=1),                  Nullable         ] public char?           FieldChar       { get; set; } // character(1)
		[Column(DataType=LinqToDB.DataType.NChar,          Length=1),                  Nullable         ] public char?           FieldNChar      { get; set; } // character(1)
		[Column(DataType=LinqToDB.DataType.Single,         Precision=24),              Nullable         ] public float?          FieldFloat      { get; set; } // real
		[Column(DataType=LinqToDB.DataType.Double,         Precision=53),              Nullable         ] public double?         FieldDouble     { get; set; } // double precision
		[Column(DataType=LinqToDB.DataType.DateTime2,      Precision=6),               Nullable         ] public DateTime?       FieldDateTime   { get; set; } // timestamp (6) without time zone
		[Column(DataType=LinqToDB.DataType.DateTimeOffset, Precision=6),               Nullable         ] public DateTimeOffset? FieldDateTime2  { get; set; } // timestamp (6) with time zone
		[Column(DataType=LinqToDB.DataType.Binary),                                    Nullable         ] public byte[]?         FieldBinary     { get; set; } // bytea
		[Column(DataType=LinqToDB.DataType.Guid),                                      Nullable         ] public Guid?           FieldGuid       { get; set; } // uuid
		[Column(DataType=LinqToDB.DataType.Decimal,        Precision=24, Scale=10),    Nullable         ] public decimal?        FieldDecimal    { get; set; } // numeric(24,10)
		[Column(DataType=LinqToDB.DataType.Date,           Precision=0),               Nullable         ] public DateTime?       FieldDate       { get; set; } // date
		[Column(DataType=LinqToDB.DataType.Time,           Precision=6),               Nullable         ] public TimeSpan?       FieldTime       { get; set; } // time(6) without time zone
		[Column(DataType=LinqToDB.DataType.NVarChar,       Length=20),                 Nullable         ] public string?         FieldEnumString { get; set; } // character varying(20)
		[Column(DataType=LinqToDB.DataType.Int32,          Precision=32, Scale=0),     Nullable         ] public int?            FieldEnumNumber { get; set; } // integer
	}

	[Table(Schema="public", Name="TestMergeIdentity")]
	public partial class TestMergeIdentity
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int  Id    { get; set; } // integer
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), Nullable            ] public int? Field { get; set; } // integer
	}

	[Table(Schema="test_schema", Name="testsamename")]
	public partial class test_schema_Testsamename
	{
		[Column("id", DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int Id { get; set; } // integer
	}

	[Table(Schema="test_schema", Name="TestSchemaIdentity")]
	public partial class test_schema_TestSchemaIdentity
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int ID { get; set; } // integer
	}

	[Table(Schema="test_schema", Name="testserialidentity")]
	public partial class test_schema_Testserialidentity
	{
		[Column(DataType=LinqToDB.DataType.Int32, Precision=32, Scale=0), PrimaryKey, Identity] public int ID { get; set; } // integer
	}

	public static partial class SqlFunctions
	{
		#region AddIfNotExists

		[Sql.Function(Name="\"public\".add_if_not_exists", ServerSideOnly=true)]
		public static object? AddIfNotExists(string? pName)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Addissue792record

		[Sql.Function(Name="\"public\".addissue792record", ServerSideOnly=true)]
		public static object? Addissue792record()
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Bool

		[Sql.Function(Name="\"public\".bool", ServerSideOnly=true)]
		public static string? Bool(int? param)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region FnTest

		[Sql.Function(Name="\"SchemaName\".\"fnTest\"", ServerSideOnly=true)]
		public static string? FnTest(int? param)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Issue1742Date

		[Sql.Function(Name="\"public\".issue_1742_date", ServerSideOnly=true)]
		public static int? Issue1742Date(DateTime? p1)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Issue1742Ts

		[Sql.Function(Name="\"public\".issue_1742_ts", ServerSideOnly=true)]
		public static int? Issue1742Ts(DateTime? p1)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Issue1742Tstz

		[Sql.Function(Name="\"public\".issue_1742_tstz", ServerSideOnly=true)]
		public static int? Issue1742Tstz(DateTimeOffset? p1)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region Reverse

		[Sql.Function(Name="\"public\".reverse", ServerSideOnly=true)]
		public static string? Reverse(string? par7)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region TestAvg

		[Sql.Function(Name="\"public\".test_avg", ServerSideOnly=true, IsAggregate = true, ArgIndices = new[] { 0 })]
		public static double? TestAvg<TSource>(this IEnumerable<TSource> src, Expression<Func<TSource, double?>> par9)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region TestFunctionParameters

		[Sql.Function(Name="\"public\".\"TestFunctionParameters\"", ServerSideOnly=true)]
		public static TestFunctionParametersResult? TestFunctionParameters(int? param1, int? param2)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region TestScalarFunction

		[Sql.Function(Name="\"public\".\"TestScalarFunction\"", ServerSideOnly=true)]
		public static string? TestScalarFunction(int? param)
		{
			throw new InvalidOperationException();
		}

		#endregion

		#region TestSingleOutParameterFunction

		[Sql.Function(Name="\"public\".\"TestSingleOutParameterFunction\"", ServerSideOnly=true)]
		public static int? TestSingleOutParameterFunction(int? param1)
		{
			throw new InvalidOperationException();
		}

		#endregion
	}

	public static partial class TableExtensions
	{
		public static _testsamename? Find(this ITable<_testsamename> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static AllType? Find(this ITable<AllType> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static Doctor? Find(this ITable<Doctor> table, int PersonID)
		{
			return table.FirstOrDefault(t =>
				t.PersonID == PersonID);
		}

		public static InheritanceChild? Find(this ITable<InheritanceChild> table, int InheritanceChildId)
		{
			return table.FirstOrDefault(t =>
				t.InheritanceChildId == InheritanceChildId);
		}

		public static InheritanceParent? Find(this ITable<InheritanceParent> table, int InheritanceParentId)
		{
			return table.FirstOrDefault(t =>
				t.InheritanceParentId == InheritanceParentId);
		}

		public static Patient? Find(this ITable<Patient> table, int PersonID)
		{
			return table.FirstOrDefault(t =>
				t.PersonID == PersonID);
		}

		public static Person? Find(this ITable<Person> table, int PersonID)
		{
			return table.FirstOrDefault(t =>
				t.PersonID == PersonID);
		}

		public static SameName? Find(this ITable<SameName> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static SameName1? Find(this ITable<SameName1> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static SameName2? Find(this ITable<SameName2> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static SequenceCustomNamingTest? Find(this ITable<SequenceCustomNamingTest> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static SequenceTest1? Find(this ITable<SequenceTest1> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static SequenceTest2? Find(this ITable<SequenceTest2> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static SequenceTest3? Find(this ITable<SequenceTest3> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static TestIdentity? Find(this ITable<TestIdentity> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static TestMerge1? Find(this ITable<TestMerge1> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static TestMerge2? Find(this ITable<TestMerge2> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static TestMergeIdentity? Find(this ITable<TestMergeIdentity> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static test_schema_Testsamename? Find(this ITable<test_schema_Testsamename> table, int Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		public static test_schema_TestSchemaIdentity? Find(this ITable<test_schema_TestSchemaIdentity> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}

		public static test_schema_Testserialidentity? Find(this ITable<test_schema_Testserialidentity> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}
	}
}
