//---------------------------------------------------------------------------------------------------
// <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.Generic;
using System.Data;
using System.Linq;

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

namespace MySqlDataContext
{
	public partial class TestdataDB : LinqToDB.Data.DataConnection
	{
		public ITable<AllType>           AllTypes            { get { return this.GetTable<AllType>(); } }
		public ITable<AllTypesNoYear>    AllTypesNoYears     { get { return this.GetTable<AllTypesNoYear>(); } }
		public ITable<Child>             Children            { get { return this.GetTable<Child>(); } }
		public ITable<CollatedTable>     CollatedTables      { get { return this.GetTable<CollatedTable>(); } }
		public ITable<DataTypeTest>      DataTypeTests       { get { return this.GetTable<DataTypeTest>(); } }
		public ITable<Doctor>            Doctors             { get { return this.GetTable<Doctor>(); } }
		public ITable<FullTextIndexTest> FullTextIndexTests  { get { return this.GetTable<FullTextIndexTest>(); } }
		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>(); } }
		public ITable<Issue1993>         Issue1993           { get { return this.GetTable<Issue1993>(); } }
		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>(); } }
		public ITable<Person>            People              { get { return this.GetTable<Person>(); } }
		/// <summary>
		/// VIEW
		/// </summary>
		public ITable<PersonView>        PersonViews         { get { return this.GetTable<PersonView>(); } }
		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<TestSameName>      TestSameNames       { get { return this.GetTable<TestSameName>(); } }

		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();
	}

	[Table("AllTypes")]
	public partial class AllType
	{
		[Column(),                      PrimaryKey, Identity] public int       ID                  { get; set; } // int
		[Column("bigintDataType"),      Nullable            ] public long?     BigintDataType      { get; set; } // bigint
		[Column("smallintDataType"),    Nullable            ] public short?    SmallintDataType    { get; set; } // smallint
		[Column("tinyintDataType"),     Nullable            ] public sbyte?    TinyintDataType     { get; set; } // tinyint
		[Column("mediumintDataType"),   Nullable            ] public int?      MediumintDataType   { get; set; } // mediumint
		[Column("intDataType"),         Nullable            ] public int?      IntDataType         { get; set; } // int
		[Column("numericDataType"),     Nullable            ] public decimal?  NumericDataType     { get; set; } // decimal(10,0)
		[Column("decimalDataType"),     Nullable            ] public decimal?  DecimalDataType     { get; set; } // decimal(10,0)
		[Column("doubleDataType"),      Nullable            ] public double?   DoubleDataType      { get; set; } // double
		[Column("floatDataType"),       Nullable            ] public float?    FloatDataType       { get; set; } // float
		[Column("dateDataType"),        Nullable            ] public DateTime? DateDataType        { get; set; } // date
		[Column("datetimeDataType"),    Nullable            ] public DateTime? DatetimeDataType    { get; set; } // datetime
		[Column("timestampDataType"),   Nullable            ] public DateTime? TimestampDataType   { get; set; } // timestamp
		[Column("timeDataType"),        Nullable            ] public TimeSpan? TimeDataType        { get; set; } // time
		[Column("yearDataType"),        Nullable            ] public int?      YearDataType        { get; set; } // year
		[Column("year2DataType"),       Nullable            ] public int?      Year2DataType       { get; set; } // year
		[Column("year4DataType"),       Nullable            ] public int?      Year4DataType       { get; set; } // year
		[Column("charDataType"),        Nullable            ] public char?     CharDataType        { get; set; } // char(1)
		[Column("char20DataType"),      Nullable            ] public string?   Char20DataType      { get; set; } // char(20)
		[Column("varcharDataType"),     Nullable            ] public string?   VarcharDataType     { get; set; } // varchar(20)
		[Column("textDataType"),        Nullable            ] public string?   TextDataType        { get; set; } // text
		[Column("binaryDataType"),      Nullable            ] public byte[]?   BinaryDataType      { get; set; } // binary(3)
		[Column("varbinaryDataType"),   Nullable            ] public byte[]?   VarbinaryDataType   { get; set; } // varbinary(5)
		[Column("blobDataType"),        Nullable            ] public byte[]?   BlobDataType        { get; set; } // blob
		[Column("bitDataType"),         Nullable            ] public byte?     BitDataType         { get; set; } // bit(3)
		[Column("enumDataType"),        Nullable            ] public string?   EnumDataType        { get; set; } // enum('Green','Red','Blue')
		[Column("setDataType"),         Nullable            ] public string?   SetDataType         { get; set; } // set('one','two')
		[Column("intUnsignedDataType"), Nullable            ] public uint?     IntUnsignedDataType { get; set; } // int unsigned
		[Column("boolDataType"),        Nullable            ] public bool?     BoolDataType        { get; set; } // tinyint(1)
	}

	[Table("AllTypesNoYear")]
	public partial class AllTypesNoYear
	{
		[Column(),                      PrimaryKey, Identity] public int       ID                  { get; set; } // int
		[Column("bigintDataType"),      Nullable            ] public long?     BigintDataType      { get; set; } // bigint
		[Column("smallintDataType"),    Nullable            ] public short?    SmallintDataType    { get; set; } // smallint
		[Column("tinyintDataType"),     Nullable            ] public sbyte?    TinyintDataType     { get; set; } // tinyint
		[Column("mediumintDataType"),   Nullable            ] public int?      MediumintDataType   { get; set; } // mediumint
		[Column("intDataType"),         Nullable            ] public int?      IntDataType         { get; set; } // int
		[Column("numericDataType"),     Nullable            ] public decimal?  NumericDataType     { get; set; } // decimal(10,0)
		[Column("decimalDataType"),     Nullable            ] public decimal?  DecimalDataType     { get; set; } // decimal(10,0)
		[Column("doubleDataType"),      Nullable            ] public double?   DoubleDataType      { get; set; } // double
		[Column("floatDataType"),       Nullable            ] public float?    FloatDataType       { get; set; } // float
		[Column("dateDataType"),        Nullable            ] public DateTime? DateDataType        { get; set; } // date
		[Column("datetimeDataType"),    Nullable            ] public DateTime? DatetimeDataType    { get; set; } // datetime
		[Column("timestampDataType"),   Nullable            ] public DateTime? TimestampDataType   { get; set; } // timestamp
		[Column("timeDataType"),        Nullable            ] public TimeSpan? TimeDataType        { get; set; } // time
		[Column("charDataType"),        Nullable            ] public char?     CharDataType        { get; set; } // char(1)
		[Column("char20DataType"),      Nullable            ] public string?   Char20DataType      { get; set; } // char(20)
		[Column("varcharDataType"),     Nullable            ] public string?   VarcharDataType     { get; set; } // varchar(20)
		[Column("textDataType"),        Nullable            ] public string?   TextDataType        { get; set; } // text
		[Column("binaryDataType"),      Nullable            ] public byte[]?   BinaryDataType      { get; set; } // binary(3)
		[Column("varbinaryDataType"),   Nullable            ] public byte[]?   VarbinaryDataType   { get; set; } // varbinary(5)
		[Column("blobDataType"),        Nullable            ] public byte[]?   BlobDataType        { get; set; } // blob
		[Column("bitDataType"),         Nullable            ] public byte?     BitDataType         { get; set; } // bit(3)
		[Column("enumDataType"),        Nullable            ] public string?   EnumDataType        { get; set; } // enum('Green','Red','Blue')
		[Column("setDataType"),         Nullable            ] public string?   SetDataType         { get; set; } // set('one','two')
		[Column("intUnsignedDataType"), Nullable            ] public uint?     IntUnsignedDataType { get; set; } // int unsigned
		[Column("boolDataType"),        Nullable            ] public bool?     BoolDataType        { get; set; } // tinyint(1)
	}

	[Table("Child")]
	public partial class Child
	{
		[Column, Nullable] public int? ParentID { get; set; } // int
		[Column, Nullable] public int? ChildID  { get; set; } // int
	}

	[Table("CollatedTable")]
	public partial class CollatedTable
	{
		[Column, NotNull] public int    Id              { get; set; } // int
		[Column, NotNull] public string CaseSensitive   { get; set; } = null!; // varchar(20)
		[Column, NotNull] public string CaseInsensitive { get; set; } = null!; // varchar(20)
	}

	[Table("DataTypeTest")]
	public partial class DataTypeTest
	{
		[Column(),            PrimaryKey,  Identity] public int       DataTypeID { get; set; } // int
		[Column("Binary_"),      Nullable          ] public byte[]?   Binary     { get; set; } // binary(50)
		[Column("Boolean_"),  NotNull              ] public bool      Boolean    { get; set; } // bit(1)
		[Column("Byte_"),        Nullable          ] public sbyte?    Byte       { get; set; } // tinyint
		[Column("Bytes_"),       Nullable          ] public byte[]?   Bytes      { get; set; } // varbinary(50)
		[Column("Char_"),        Nullable          ] public char?     Char       { get; set; } // char(1)
		[Column("DateTime_"),    Nullable          ] public DateTime? DateTime   { get; set; } // datetime
		[Column("Decimal_"),     Nullable          ] public decimal?  Decimal    { get; set; } // decimal(20,2)
		[Column("Double_"),      Nullable          ] public float?    Double     { get; set; } // float
		[Column("Guid_"),        Nullable          ] public byte[]?   Guid       { get; set; } // varbinary(50)
		[Column("Int16_"),       Nullable          ] public short?    Int16      { get; set; } // smallint
		[Column("Int32_"),       Nullable          ] public int?      Int32      { get; set; } // int
		[Column("Int64_"),       Nullable          ] public long?     Int64      { get; set; } // bigint
		[Column("Money_"),       Nullable          ] public decimal?  Money      { get; set; } // decimal(20,4)
		[Column("SByte_"),       Nullable          ] public sbyte?    SByte      { get; set; } // tinyint
		[Column("Single_"),      Nullable          ] public double?   Single     { get; set; } // double
		[Column("Stream_"),      Nullable          ] public byte[]?   Stream     { get; set; } // varbinary(50)
		[Column("String_"),      Nullable          ] public string?   String     { get; set; } // varchar(50)
		[Column("UInt16_"),      Nullable          ] public short?    UInt16     { get; set; } // smallint
		[Column("UInt32_"),      Nullable          ] public int?      UInt32     { get; set; } // int
		[Column("UInt64_"),      Nullable          ] public long?     UInt64     { get; set; } // bigint
		[Column("Xml_"),         Nullable          ] public string?   Xml        { get; set; } // varchar(1000)
	}

	[Table("Doctor")]
	public partial class Doctor
	{
		[PrimaryKey, NotNull] public int    PersonID { get; set; } // int
		[Column,     NotNull] public string Taxonomy { get; set; } = null!; // varchar(50)

		#region Associations

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

		#endregion
	}

	[Table("FullTextIndexTest")]
	public partial class FullTextIndexTest
	{
		[Column("id"), PrimaryKey, Identity] public uint    Id         { get; set; } // int unsigned
		[Column(),     Nullable            ] public string? TestField1 { get; set; } // text
		[Column(),     Nullable            ] public string? TestField2 { get; set; } // text
	}

	[Table("GrandChild")]
	public partial class GrandChild
	{
		[Column, Nullable] public int? ParentID     { get; set; } // int
		[Column, Nullable] public int? ChildID      { get; set; } // int
		[Column, Nullable] public int? GrandChildID { get; set; } // int
	}

	[Table("InheritanceChild")]
	public partial class InheritanceChild
	{
		[PrimaryKey, NotNull    ] public int     InheritanceChildId  { get; set; } // int
		[Column,     NotNull    ] public int     InheritanceParentId { get; set; } // int
		[Column,        Nullable] public int?    TypeDiscriminator   { get; set; } // int
		[Column,        Nullable] public string? Name                { get; set; } // varchar(50)
	}

	[Table("InheritanceParent")]
	public partial class InheritanceParent
	{
		[PrimaryKey, NotNull    ] public int     InheritanceParentId { get; set; } // int
		[Column,        Nullable] public int?    TypeDiscriminator   { get; set; } // int
		[Column,        Nullable] public string? Name                { get; set; } // varchar(50)
	}

	[Table("Issue1993")]
	public partial class Issue1993
	{
		[Column("id"),          PrimaryKey, Identity] public uint    Id          { get; set; } // int unsigned
		[Column("description"), Nullable            ] public string? Description { get; set; } // varchar(100)
	}

	[Table("LinqDataTypes")]
	public partial class LinqDataType
	{
		[Column, Nullable] public int?      ID             { get; set; } // int
		[Column, Nullable] public decimal?  MoneyValue     { get; set; } // decimal(10,4)
		[Column, Nullable] public DateTime? DateTimeValue  { get; set; } // datetime(3)
		[Column, Nullable] public DateTime? DateTimeValue2 { get; set; } // datetime
		[Column, Nullable] public bool?     BoolValue      { get; set; } // tinyint(1)
		[Column, Nullable] public string?   GuidValue      { get; set; } // char(36)
		[Column, Nullable] public byte[]?   BinaryValue    { get; set; } // varbinary(5000)
		[Column, Nullable] public short?    SmallIntValue  { get; set; } // smallint
		[Column, Nullable] public int?      IntValue       { get; set; } // int
		[Column, Nullable] public long?     BigIntValue    { get; set; } // bigint
		[Column, Nullable] public string?   StringValue    { get; set; } // varchar(50)
	}

	[Table("Parent")]
	public partial class Parent
	{
		[Column, Nullable] public int? ParentID { get; set; } // int
		[Column, Nullable] public int? Value1   { get; set; } // int
	}

	[Table("Patient")]
	public partial class Patient
	{
		[PrimaryKey, NotNull] public int    PersonID  { get; set; } // int
		[Column,     NotNull] public string Diagnosis { get; set; } = null!; // varchar(256)

		#region Associations

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

		#endregion
	}

	[Table("Person")]
	public partial class Person
	{
		[PrimaryKey, Identity   ] public int     PersonID   { get; set; } // int
		[Column,     NotNull    ] public string  FirstName  { get; set; } = null!; // varchar(50)
		[Column,     NotNull    ] public string  LastName   { get; set; } = null!; // varchar(50)
		[Column,        Nullable] public string? MiddleName { get; set; } // varchar(50)
		[Column,     NotNull    ] public char    Gender     { get; set; } // char(1)

		#region Associations

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

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

		#endregion
	}

	/// <summary>
	/// VIEW
	/// </summary>
	[Table("PersonView", IsView=true)]
	public partial class PersonView
	{
		[Column, NotNull] public int ID { get; set; } // int
	}

	[Table("TestIdentity")]
	public partial class TestIdentity
	{
		[PrimaryKey, Identity] public int ID { get; set; } // int
	}

	[Table("TestMerge1")]
	public partial class TestMerge1
	{
		[PrimaryKey, NotNull    ] public int       Id              { get; set; } // int
		[Column,        Nullable] public int?      Field1          { get; set; } // int
		[Column,        Nullable] public int?      Field2          { get; set; } // int
		[Column,        Nullable] public int?      Field3          { get; set; } // int
		[Column,        Nullable] public int?      Field4          { get; set; } // int
		[Column,        Nullable] public int?      Field5          { get; set; } // int
		[Column,        Nullable] public long?     FieldInt64      { get; set; } // bigint
		[Column,        Nullable] public bool?     FieldBoolean    { get; set; } // bit(1)
		[Column,        Nullable] public string?   FieldString     { get; set; } // varchar(20)
		[Column,        Nullable] public string?   FieldNString    { get; set; } // varchar(20)
		[Column,        Nullable] public char?     FieldChar       { get; set; } // char(1)
		[Column,        Nullable] public char?     FieldNChar      { get; set; } // char(1)
		[Column,        Nullable] public float?    FieldFloat      { get; set; } // float
		[Column,        Nullable] public double?   FieldDouble     { get; set; } // double
		[Column,        Nullable] public DateTime? FieldDateTime   { get; set; } // datetime
		[Column,        Nullable] public byte[]?   FieldBinary     { get; set; } // varbinary(20)
		[Column,        Nullable] public string?   FieldGuid       { get; set; } // char(36)
		[Column,        Nullable] public decimal?  FieldDecimal    { get; set; } // decimal(24,10)
		[Column,        Nullable] public DateTime? FieldDate       { get; set; } // date
		[Column,        Nullable] public TimeSpan? FieldTime       { get; set; } // time
		[Column,        Nullable] public string?   FieldEnumString { get; set; } // varchar(20)
		[Column,        Nullable] public int?      FieldEnumNumber { get; set; } // int
	}

	[Table("TestMerge2")]
	public partial class TestMerge2
	{
		[PrimaryKey, NotNull    ] public int       Id              { get; set; } // int
		[Column,        Nullable] public int?      Field1          { get; set; } // int
		[Column,        Nullable] public int?      Field2          { get; set; } // int
		[Column,        Nullable] public int?      Field3          { get; set; } // int
		[Column,        Nullable] public int?      Field4          { get; set; } // int
		[Column,        Nullable] public int?      Field5          { get; set; } // int
		[Column,        Nullable] public long?     FieldInt64      { get; set; } // bigint
		[Column,        Nullable] public bool?     FieldBoolean    { get; set; } // bit(1)
		[Column,        Nullable] public string?   FieldString     { get; set; } // varchar(20)
		[Column,        Nullable] public string?   FieldNString    { get; set; } // varchar(20)
		[Column,        Nullable] public char?     FieldChar       { get; set; } // char(1)
		[Column,        Nullable] public char?     FieldNChar      { get; set; } // char(1)
		[Column,        Nullable] public float?    FieldFloat      { get; set; } // float
		[Column,        Nullable] public double?   FieldDouble     { get; set; } // double
		[Column,        Nullable] public DateTime? FieldDateTime   { get; set; } // datetime
		[Column,        Nullable] public byte[]?   FieldBinary     { get; set; } // varbinary(20)
		[Column,        Nullable] public string?   FieldGuid       { get; set; } // char(36)
		[Column,        Nullable] public decimal?  FieldDecimal    { get; set; } // decimal(24,10)
		[Column,        Nullable] public DateTime? FieldDate       { get; set; } // date
		[Column,        Nullable] public TimeSpan? FieldTime       { get; set; } // time
		[Column,        Nullable] public string?   FieldEnumString { get; set; } // varchar(20)
		[Column,        Nullable] public int?      FieldEnumNumber { get; set; } // int
	}

	[Table("TestSameName")]
	public partial class TestSameName
	{
		[PrimaryKey, NotNull] public int ID { get; set; } // int
	}

	public static partial class TestdataDBStoredProcedures
	{
		#region AddIssue792Record

		public static int AddIssue792Record(this TestdataDB dataConnection)
		{
			return dataConnection.ExecuteProc("`AddIssue792Record`");
		}

		#endregion

		#region Issue2313Parameters

		public static IEnumerable<Issue2313ParametersResult> Issue2313Parameters(this TestdataDB dataConnection, string? varCharDefault, char? varChar1, string? char255, char? char1, byte[]? varBinary255, byte[]? binary255, byte[]? tinyBlob, byte[]? blob, byte[]? mediumBlob, byte[]? longBlob, string? tinyText, string? text, string? mediumText, string? longText, DateTime? date, DateTime? dateTime, DateTime? timeStamp, TimeSpan? time, string? json, sbyte? tinyInt, byte? tinyIntUnsigned, short? smallInt, ushort? smallIntUnsigned, int? mediumInt, uint? mediumIntUnsigned, int? @int, uint? intUnsigned, long? bigInt, ulong? bigIntUnsigned, decimal? @decimal, float? @float, double? @double, bool? boolean, bool? bit1, byte? bit8, ushort? bit10, ushort? bit16, uint? bit32, ulong? bit64, string? @enum, string? set, int? year, byte[]? geometry, byte[]? point, byte[]? lineString, byte[]? polygon, byte[]? multiPoint, byte[]? multiLineString, byte[]? multiPolygon, byte[]? geometryCollection)
		{
			var parameters = new []
			{
				new DataParameter("VarCharDefault",     varCharDefault,     LinqToDB.DataType.VarChar)
				{
					Size = 255
				},
				new DataParameter("VarChar1",           varChar1,           LinqToDB.DataType.VarChar)
				{
					Size = 1
				},
				new DataParameter("Char255",            char255,            LinqToDB.DataType.Char)
				{
					Size = 255
				},
				new DataParameter("Char1",              char1,              LinqToDB.DataType.Char)
				{
					Size = 1
				},
				new DataParameter("VarBinary255",       varBinary255,       LinqToDB.DataType.VarBinary)
				{
					Size = 255
				},
				new DataParameter("Binary255",          binary255,          LinqToDB.DataType.Binary)
				{
					Size = 255
				},
				new DataParameter("TinyBlob",           tinyBlob,           LinqToDB.DataType.Blob)
				{
					Size = 255
				},
				new DataParameter("Blob",               blob,               LinqToDB.DataType.Blob)
				{
					Size = 65535
				},
				new DataParameter("MediumBlob",         mediumBlob,         LinqToDB.DataType.Blob)
				{
					Size = 16777215
				},
				new DataParameter("LongBlob",           longBlob,           LinqToDB.DataType.Blob),
				new DataParameter("TinyText",           tinyText,           LinqToDB.DataType.Text)
				{
					Size = 255
				},
				new DataParameter("Text",               text,               LinqToDB.DataType.Text)
				{
					Size = 65535
				},
				new DataParameter("MediumText",         mediumText,         LinqToDB.DataType.Text)
				{
					Size = 16777215
				},
				new DataParameter("LongText",           longText,           LinqToDB.DataType.Text),
				new DataParameter("Date",               date,               LinqToDB.DataType.Date),
				new DataParameter("DateTime",           dateTime,           LinqToDB.DataType.DateTime),
				new DataParameter("TimeStamp",          timeStamp,          LinqToDB.DataType.DateTime),
				new DataParameter("Time",               time,               LinqToDB.DataType.Time),
				new DataParameter("Json",               json,               LinqToDB.DataType.Json),
				new DataParameter("TinyInt",            tinyInt,            LinqToDB.DataType.SByte),
				new DataParameter("TinyIntUnsigned",    tinyIntUnsigned,    LinqToDB.DataType.Byte),
				new DataParameter("SmallInt",           smallInt,           LinqToDB.DataType.Int16),
				new DataParameter("SmallIntUnsigned",   smallIntUnsigned,   LinqToDB.DataType.UInt16),
				new DataParameter("MediumInt",          mediumInt,          LinqToDB.DataType.Int32),
				new DataParameter("MediumIntUnsigned",  mediumIntUnsigned,  LinqToDB.DataType.UInt32),
				new DataParameter("Int",                @int,               LinqToDB.DataType.Int32),
				new DataParameter("IntUnsigned",        intUnsigned,        LinqToDB.DataType.UInt32),
				new DataParameter("BigInt",             bigInt,             LinqToDB.DataType.Int64),
				new DataParameter("BigIntUnsigned",     bigIntUnsigned,     LinqToDB.DataType.UInt64),
				new DataParameter("Decimal",            @decimal,           LinqToDB.DataType.Decimal),
				new DataParameter("Float",              @float,             LinqToDB.DataType.Single),
				new DataParameter("Double",             @double,            LinqToDB.DataType.Double),
				new DataParameter("Boolean",            boolean,            LinqToDB.DataType.SByte),
				new DataParameter("Bit1",               bit1,               LinqToDB.DataType.BitArray),
				new DataParameter("Bit8",               bit8,               LinqToDB.DataType.BitArray),
				new DataParameter("Bit10",              bit10,              LinqToDB.DataType.BitArray),
				new DataParameter("Bit16",              bit16,              LinqToDB.DataType.BitArray),
				new DataParameter("Bit32",              bit32,              LinqToDB.DataType.BitArray),
				new DataParameter("Bit64",              bit64,              LinqToDB.DataType.BitArray),
				new DataParameter("Enum",               @enum,              LinqToDB.DataType.VarChar)
				{
					Size = 3
				},
				new DataParameter("Set",                set,                LinqToDB.DataType.VarChar)
				{
					Size = 3
				},
				new DataParameter("Year",               year,               LinqToDB.DataType.Int32),
				new DataParameter("Geometry",           geometry,           LinqToDB.DataType.Undefined),
				new DataParameter("Point",              point,              LinqToDB.DataType.Undefined),
				new DataParameter("LineString",         lineString,         LinqToDB.DataType.Undefined),
				new DataParameter("Polygon",            polygon,            LinqToDB.DataType.Undefined),
				new DataParameter("MultiPoint",         multiPoint,         LinqToDB.DataType.Undefined),
				new DataParameter("MultiLineString",    multiLineString,    LinqToDB.DataType.Undefined),
				new DataParameter("MultiPolygon",       multiPolygon,       LinqToDB.DataType.Undefined),
				new DataParameter("GeometryCollection", geometryCollection, LinqToDB.DataType.Undefined)
			};

			return dataConnection.QueryProc<Issue2313ParametersResult>("`Issue2313Parameters`", parameters);
		}

		public partial class Issue2313ParametersResult
		{
			[Column("`VarCharDefault`")    ] public string?   VarCharDefault     { get; set; }
			[Column("`VarChar1`")          ] public char?     VarChar1           { get; set; }
			[Column("`Char255`")           ] public string?   Char255            { get; set; }
			[Column("`Char1`")             ] public char?     Char1              { get; set; }
			[Column("`VarBinary255`")      ] public byte[]?   VarBinary255       { get; set; }
			[Column("`Binary255`")         ] public byte[]?   Binary255          { get; set; }
			[Column("`TinyBlob`")          ] public byte[]?   TinyBlob           { get; set; }
			[Column("`Blob`")              ] public byte[]?   Blob               { get; set; }
			[Column("`MediumBlob`")        ] public byte[]?   MediumBlob         { get; set; }
			[Column("`LongBlob`")          ] public byte[]?   LongBlob           { get; set; }
			[Column("`TinyText`")          ] public string?   TinyText           { get; set; }
			[Column("`Text`")              ] public string?   Text               { get; set; }
			[Column("`MediumText`")        ] public string?   MediumText         { get; set; }
			[Column("`LongText`")          ] public string?   LongText           { get; set; }
			[Column("`Date`")              ] public DateTime? Date               { get; set; }
			[Column("`DateTime`")          ] public DateTime? DateTime           { get; set; }
			[Column("`TimeStamp`")         ] public DateTime? TimeStamp          { get; set; }
			[Column("`Time`")              ] public TimeSpan? Time               { get; set; }
			[Column("`Json`")              ] public string?   Json               { get; set; }
			[Column("`TinyInt`")           ] public sbyte?    TinyInt            { get; set; }
			[Column("`TinyIntUnsigned`")   ] public byte?     TinyIntUnsigned    { get; set; }
			[Column("`SmallInt`")          ] public short?    SmallInt           { get; set; }
			[Column("`SmallIntUnsigned`")  ] public ushort?   SmallIntUnsigned   { get; set; }
			[Column("`MediumInt`")         ] public int?      MediumInt          { get; set; }
			[Column("`MediumIntUnsigned`") ] public uint?     MediumIntUnsigned  { get; set; }
			[Column("`Int`")               ] public int?      Int                { get; set; }
			[Column("`IntUnsigned`")       ] public uint?     IntUnsigned        { get; set; }
			[Column("`BigInt`")            ] public long?     BigInt             { get; set; }
			[Column("`BigIntUnsigned`")    ] public ulong?    BigIntUnsigned     { get; set; }
			[Column("`Decimal`")           ] public decimal?  Decimal            { get; set; }
			[Column("`Float`")             ] public float?    Float              { get; set; }
			[Column("`Double`")            ] public double?   Double             { get; set; }
			[Column("`Boolean`")           ] public bool?     Boolean            { get; set; }
			[Column("`Bit1`")              ] public bool?     Bit1               { get; set; }
			[Column("`Bit8`")              ] public byte?     Bit8               { get; set; }
			[Column("`Bit10`")             ] public ushort?   Bit10              { get; set; }
			[Column("`Bit16`")             ] public ushort?   Bit16              { get; set; }
			[Column("`Bit32`")             ] public uint?     Bit32              { get; set; }
			[Column("`Bit64`")             ] public ulong?    Bit64              { get; set; }
			[Column("`Enum`")              ] public string?   Enum               { get; set; }
			[Column("`Set`")               ] public string?   Set                { get; set; }
			[Column("`Year`")              ] public int?      Year               { get; set; }
			[Column("`Geometry`")          ] public byte[]?   Geometry           { get; set; }
			[Column("`Point`")             ] public byte[]?   Point              { get; set; }
			[Column("`LineString`")        ] public byte[]?   LineString         { get; set; }
			[Column("`Polygon`")           ] public byte[]?   Polygon            { get; set; }
			[Column("`MultiPoint`")        ] public byte[]?   MultiPoint         { get; set; }
			[Column("`MultiLineString`")   ] public byte[]?   MultiLineString    { get; set; }
			[Column("`MultiPolygon`")      ] public byte[]?   MultiPolygon       { get; set; }
			[Column("`GeometryCollection`")] public byte[]?   GeometryCollection { get; set; }
		}

		#endregion

		#region Issue2313Results

		public static IEnumerable<Issue2313ResultsResult> Issue2313Results(this TestdataDB dataConnection, string? varCharDefault, char? varChar1, string? char255, char? char1, byte[]? varBinary255, byte[]? binary255, byte[]? tinyBlob, byte[]? blob, byte[]? mediumBlob, byte[]? longBlob, string? tinyText, string? text, string? mediumText, string? longText, DateTime? date, DateTime? dateTime, DateTime? timeStamp, TimeSpan? time, sbyte? tinyInt, byte? tinyIntUnsigned, short? smallInt, ushort? smallIntUnsigned, int? mediumInt, uint? mediumIntUnsigned, int? @int, uint? intUnsigned, long? bigInt, ulong? bigIntUnsigned, decimal? @decimal, float? @float, double? @double, bool? boolean, bool? bit1, byte? bit8, ushort? bit10, ushort? bit16, uint? bit32, ulong? bit64, string? @enum, string? set, int? year)
		{
			var parameters = new []
			{
				new DataParameter("VarCharDefault",    varCharDefault,    LinqToDB.DataType.VarChar)
				{
					Size = 4000
				},
				new DataParameter("VarChar1",          varChar1,          LinqToDB.DataType.VarChar)
				{
					Size = 1
				},
				new DataParameter("Char255",           char255,           LinqToDB.DataType.Char)
				{
					Size = 255
				},
				new DataParameter("Char1",             char1,             LinqToDB.DataType.Char)
				{
					Size = 1
				},
				new DataParameter("VarBinary255",      varBinary255,      LinqToDB.DataType.VarBinary)
				{
					Size = 255
				},
				new DataParameter("Binary255",         binary255,         LinqToDB.DataType.Binary)
				{
					Size = 255
				},
				new DataParameter("TinyBlob",          tinyBlob,          LinqToDB.DataType.Blob)
				{
					Size = 255
				},
				new DataParameter("Blob",              blob,              LinqToDB.DataType.Blob)
				{
					Size = 65535
				},
				new DataParameter("MediumBlob",        mediumBlob,        LinqToDB.DataType.Blob)
				{
					Size = 16777215
				},
				new DataParameter("LongBlob",          longBlob,          LinqToDB.DataType.Blob),
				new DataParameter("TinyText",          tinyText,          LinqToDB.DataType.Text)
				{
					Size = 255
				},
				new DataParameter("Text",              text,              LinqToDB.DataType.Text)
				{
					Size = 65535
				},
				new DataParameter("MediumText",        mediumText,        LinqToDB.DataType.Text)
				{
					Size = 16777215
				},
				new DataParameter("LongText",          longText,          LinqToDB.DataType.Text),
				new DataParameter("Date",              date,              LinqToDB.DataType.Date),
				new DataParameter("DateTime",          dateTime,          LinqToDB.DataType.DateTime),
				new DataParameter("TimeStamp",         timeStamp,         LinqToDB.DataType.DateTime),
				new DataParameter("Time",              time,              LinqToDB.DataType.Time),
				new DataParameter("TinyInt",           tinyInt,           LinqToDB.DataType.SByte),
				new DataParameter("TinyIntUnsigned",   tinyIntUnsigned,   LinqToDB.DataType.Byte),
				new DataParameter("SmallInt",          smallInt,          LinqToDB.DataType.Int16),
				new DataParameter("SmallIntUnsigned",  smallIntUnsigned,  LinqToDB.DataType.UInt16),
				new DataParameter("MediumInt",         mediumInt,         LinqToDB.DataType.Int32),
				new DataParameter("MediumIntUnsigned", mediumIntUnsigned, LinqToDB.DataType.UInt32),
				new DataParameter("Int",               @int,              LinqToDB.DataType.Int32),
				new DataParameter("IntUnsigned",       intUnsigned,       LinqToDB.DataType.UInt32),
				new DataParameter("BigInt",            bigInt,            LinqToDB.DataType.Int64),
				new DataParameter("BigIntUnsigned",    bigIntUnsigned,    LinqToDB.DataType.UInt64),
				new DataParameter("Decimal",           @decimal,          LinqToDB.DataType.Decimal),
				new DataParameter("Float",             @float,            LinqToDB.DataType.Single),
				new DataParameter("Double",            @double,           LinqToDB.DataType.Double),
				new DataParameter("Boolean",           boolean,           LinqToDB.DataType.SByte),
				new DataParameter("Bit1",              bit1,              LinqToDB.DataType.BitArray),
				new DataParameter("Bit8",              bit8,              LinqToDB.DataType.BitArray),
				new DataParameter("Bit10",             bit10,             LinqToDB.DataType.BitArray),
				new DataParameter("Bit16",             bit16,             LinqToDB.DataType.BitArray),
				new DataParameter("Bit32",             bit32,             LinqToDB.DataType.BitArray),
				new DataParameter("Bit64",             bit64,             LinqToDB.DataType.BitArray),
				new DataParameter("Enum",              @enum,             LinqToDB.DataType.VarChar)
				{
					Size = 3
				},
				new DataParameter("Set",               set,               LinqToDB.DataType.VarChar)
				{
					Size = 3
				},
				new DataParameter("Year",              year,              LinqToDB.DataType.Int32)
			};

			return dataConnection.QueryProc<Issue2313ResultsResult>("`Issue2313Results`", parameters);
		}

		public partial class Issue2313ResultsResult
		{
			[Column("`VarCharDefault`")   ] public string?   VarCharDefault    { get; set; }
			[Column("`VarChar1`")         ] public char?     VarChar1          { get; set; }
			[Column("`Char255`")          ] public string?   Char255           { get; set; }
			[Column("`Char1`")            ] public char?     Char1             { get; set; }
			[Column("`VarBinary255`")     ] public byte[]?   VarBinary255      { get; set; }
			[Column("`Binary255`")        ] public byte[]?   Binary255         { get; set; }
			[Column("`TinyBlob`")         ] public byte[]?   TinyBlob          { get; set; }
			[Column("`Blob`")             ] public byte[]?   Blob              { get; set; }
			[Column("`MediumBlob`")       ] public byte[]?   MediumBlob        { get; set; }
			[Column("`LongBlob`")         ] public byte[]?   LongBlob          { get; set; }
			[Column("`TinyText`")         ] public string?   TinyText          { get; set; }
			[Column("`Text`")             ] public string?   Text              { get; set; }
			[Column("`MediumText`")       ] public string?   MediumText        { get; set; }
			[Column("`LongText`")         ] public string?   LongText          { get; set; }
			[Column("`Date`")             ] public DateTime? Date              { get; set; }
			[Column("`DateTime`")         ] public DateTime? DateTime          { get; set; }
			[Column("`TimeStamp`")        ] public DateTime? TimeStamp         { get; set; }
			[Column("`Time`")             ] public TimeSpan? Time              { get; set; }
			[Column("`TinyInt`")          ] public sbyte?    TinyInt           { get; set; }
			[Column("`TinyIntUnsigned`")  ] public byte?     TinyIntUnsigned   { get; set; }
			[Column("`SmallInt`")         ] public short?    SmallInt          { get; set; }
			[Column("`SmallIntUnsigned`") ] public ushort?   SmallIntUnsigned  { get; set; }
			[Column("`MediumInt`")        ] public int?      MediumInt         { get; set; }
			[Column("`MediumIntUnsigned`")] public uint?     MediumIntUnsigned { get; set; }
			[Column("`Int`")              ] public int?      Int               { get; set; }
			[Column("`IntUnsigned`")      ] public uint?     IntUnsigned       { get; set; }
			[Column("`BigInt`")           ] public long?     BigInt            { get; set; }
			[Column("`BigIntUnsigned`")   ] public ulong?    BigIntUnsigned    { get; set; }
			[Column("`Decimal`")          ] public decimal?  Decimal           { get; set; }
			[Column("`Float`")            ] public float?    Float             { get; set; }
			[Column("`Double`")           ] public double?   Double            { get; set; }
			[Column("`Boolean`")          ] public bool?     Boolean           { get; set; }
			[Column("`Bit1`")             ] public bool?     Bit1              { get; set; }
			[Column("`Bit8`")             ] public byte?     Bit8              { get; set; }
			[Column("`Bit10`")            ] public ushort?   Bit10             { get; set; }
			[Column("`Bit16`")            ] public ushort?   Bit16             { get; set; }
			[Column("`Bit32`")            ] public uint?     Bit32             { get; set; }
			[Column("`Bit64`")            ] public ulong?    Bit64             { get; set; }
			[Column("`Enum`")             ] public string?   Enum              { get; set; }
			[Column("`Set`")              ] public string?   Set               { get; set; }
			[Column("`Year`")             ] public int?      Year              { get; set; }
		}

		#endregion

		#region TestOutputParametersWithoutTableProcedure

		public static int TestOutputParametersWithoutTableProcedure(this TestdataDB dataConnection, string? aInParam, out bool? aOutParam)
		{
			var parameters = new []
			{
				new DataParameter("aInParam",  aInParam,  LinqToDB.DataType.VarChar)
				{
					Size = 256
				},
				new DataParameter("aOutParam", null, LinqToDB.DataType.SByte)
				{
					Direction = ParameterDirection.Output
				}
			};

			var ret = dataConnection.ExecuteProc("`TestOutputParametersWithoutTableProcedure`", parameters);

			aOutParam = Converter.ChangeTypeTo<bool?>(parameters[1].Value);

			return ret;
		}

		#endregion

		#region TestProcedure

		public static IEnumerable<Person> TestProcedure(this TestdataDB dataConnection, int? param3, ref int? param2, out int? param1)
		{
			var parameters = new []
			{
				new DataParameter("param3", param3, LinqToDB.DataType.Int32),
				new DataParameter("param2", param2, LinqToDB.DataType.Int32)
				{
					Direction = ParameterDirection.InputOutput
				},
				new DataParameter("param1", null, LinqToDB.DataType.Int32)
				{
					Direction = ParameterDirection.Output
				}
			};

			var ret = dataConnection.QueryProc<Person>("`TestProcedure`", parameters).ToList();

			param2 = Converter.ChangeTypeTo<int?>(parameters[1].Value);
			param1 = Converter.ChangeTypeTo<int?>(parameters[2].Value);

			return ret;
		}

		#endregion
	}

	public static partial class SqlFunctions
	{
		#region TestFunction

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

		#endregion
	}

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

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

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

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

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

		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 Issue1993? Find(this ITable<Issue1993> table, uint Id)
		{
			return table.FirstOrDefault(t =>
				t.Id == Id);
		}

		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 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 TestSameName? Find(this ITable<TestSameName> table, int ID)
		{
			return table.FirstOrDefault(t =>
				t.ID == ID);
		}
	}
}
