BulkWriters256

Last 128 "bulk writers".
git clone https://git.philomathiclife.com/repos/BulkWriters256
Log | Files | Refs | README

BulkWriters.cs (3428814B)


      1 // This code was generated via a CLI app that used the source code in BulkWriterBaseCase.cs as a template.
      2 // To improve compilation performance, the code uses very little 'whitespace' beyond what is necessary and contains no documentation, warning suppressions, or comments.
      3 using Microsoft.Data.SqlClient;
      4 using Serde.Bin.Ser;
      5 using Std;
      6 using Std.Iter;
      7 using Std.Maybe;
      8 using Std.Num;
      9 using Std.Result;
     10 using System;
     11 using System.Data;
     12 using System.Diagnostics;
     13 using static SQLServer.Helpers;
     14 using System.Runtime.InteropServices;
     15 #pragma warning disable CA1005, CA1045, CA1051, CA1062, CA1066, CA1815, CA2100, CA2231, IDE0032
     16 namespace SQLServer {
     17 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     18 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     19 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     20 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     21 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     22 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     23 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     24 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     25 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     26 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     27 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     28 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     29 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     30 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     31 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     32 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     33 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     34 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     35 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     36 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     37 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     38 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     39 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     40 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     41 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     42 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     43 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     44 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     45 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     46 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     47 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     48 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     49 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     50 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     51 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     52 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     53 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     54 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     55 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     56 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     57 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     58 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     59 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     60 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     61 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     62 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     63 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     64 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     65 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     66 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     67 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     68 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     69 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     70 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     71 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     72 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     73 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     74 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     75 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     76 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     77 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     78 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     79 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     80 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     81 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     82 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     83 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     84 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     85 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     86 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     87 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     88 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     89 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     90 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     91 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     92 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     93 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     94 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     95 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     96 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     97 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     98 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
     99 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    100 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    101 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    102 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    103 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    104 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    105 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    106 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    107 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    108 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    109 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    110 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    111 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    112 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    113 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    114 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    115 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    116 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    117 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    118 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    119 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    120 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    121 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    122 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    123 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    124 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    125 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    126 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    127 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    128 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    129 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    130 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    131 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    132 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    133 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    134 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    135 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    136 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    137 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    138 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    139 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    140 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType where T251:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),251=>new(typeof(T251)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    141 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType where T251:struct,IDataType where T252:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),251=>new(typeof(T251)),252=>new(typeof(T252)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    142 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType where T251:struct,IDataType where T252:struct,IDataType where T253:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),251=>new(typeof(T251)),252=>new(typeof(T252)),253=>new(typeof(T253)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    143 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType where T251:struct,IDataType where T252:struct,IDataType where T253:struct,IDataType where T254:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),251=>new(typeof(T251)),252=>new(typeof(T252)),253=>new(typeof(T253)),254=>new(typeof(T254)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    144 [StructLayout(LayoutKind.Sequential,CharSet=CharSet.Unicode,Pack= 0)]public struct BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>:IBulkWriter where T0:struct,IDataType where T1:struct,IDataType where T2:struct,IDataType where T3:struct,IDataType where T4:struct,IDataType where T5:struct,IDataType where T6:struct,IDataType where T7:struct,IDataType where T8:struct,IDataType where T9:struct,IDataType where T10:struct,IDataType where T11:struct,IDataType where T12:struct,IDataType where T13:struct,IDataType where T14:struct,IDataType where T15:struct,IDataType where T16:struct,IDataType where T17:struct,IDataType where T18:struct,IDataType where T19:struct,IDataType where T20:struct,IDataType where T21:struct,IDataType where T22:struct,IDataType where T23:struct,IDataType where T24:struct,IDataType where T25:struct,IDataType where T26:struct,IDataType where T27:struct,IDataType where T28:struct,IDataType where T29:struct,IDataType where T30:struct,IDataType where T31:struct,IDataType where T32:struct,IDataType where T33:struct,IDataType where T34:struct,IDataType where T35:struct,IDataType where T36:struct,IDataType where T37:struct,IDataType where T38:struct,IDataType where T39:struct,IDataType where T40:struct,IDataType where T41:struct,IDataType where T42:struct,IDataType where T43:struct,IDataType where T44:struct,IDataType where T45:struct,IDataType where T46:struct,IDataType where T47:struct,IDataType where T48:struct,IDataType where T49:struct,IDataType where T50:struct,IDataType where T51:struct,IDataType where T52:struct,IDataType where T53:struct,IDataType where T54:struct,IDataType where T55:struct,IDataType where T56:struct,IDataType where T57:struct,IDataType where T58:struct,IDataType where T59:struct,IDataType where T60:struct,IDataType where T61:struct,IDataType where T62:struct,IDataType where T63:struct,IDataType where T64:struct,IDataType where T65:struct,IDataType where T66:struct,IDataType where T67:struct,IDataType where T68:struct,IDataType where T69:struct,IDataType where T70:struct,IDataType where T71:struct,IDataType where T72:struct,IDataType where T73:struct,IDataType where T74:struct,IDataType where T75:struct,IDataType where T76:struct,IDataType where T77:struct,IDataType where T78:struct,IDataType where T79:struct,IDataType where T80:struct,IDataType where T81:struct,IDataType where T82:struct,IDataType where T83:struct,IDataType where T84:struct,IDataType where T85:struct,IDataType where T86:struct,IDataType where T87:struct,IDataType where T88:struct,IDataType where T89:struct,IDataType where T90:struct,IDataType where T91:struct,IDataType where T92:struct,IDataType where T93:struct,IDataType where T94:struct,IDataType where T95:struct,IDataType where T96:struct,IDataType where T97:struct,IDataType where T98:struct,IDataType where T99:struct,IDataType where T100:struct,IDataType where T101:struct,IDataType where T102:struct,IDataType where T103:struct,IDataType where T104:struct,IDataType where T105:struct,IDataType where T106:struct,IDataType where T107:struct,IDataType where T108:struct,IDataType where T109:struct,IDataType where T110:struct,IDataType where T111:struct,IDataType where T112:struct,IDataType where T113:struct,IDataType where T114:struct,IDataType where T115:struct,IDataType where T116:struct,IDataType where T117:struct,IDataType where T118:struct,IDataType where T119:struct,IDataType where T120:struct,IDataType where T121:struct,IDataType where T122:struct,IDataType where T123:struct,IDataType where T124:struct,IDataType where T125:struct,IDataType where T126:struct,IDataType where T127:struct,IDataType where T128:struct,IDataType where T129:struct,IDataType where T130:struct,IDataType where T131:struct,IDataType where T132:struct,IDataType where T133:struct,IDataType where T134:struct,IDataType where T135:struct,IDataType where T136:struct,IDataType where T137:struct,IDataType where T138:struct,IDataType where T139:struct,IDataType where T140:struct,IDataType where T141:struct,IDataType where T142:struct,IDataType where T143:struct,IDataType where T144:struct,IDataType where T145:struct,IDataType where T146:struct,IDataType where T147:struct,IDataType where T148:struct,IDataType where T149:struct,IDataType where T150:struct,IDataType where T151:struct,IDataType where T152:struct,IDataType where T153:struct,IDataType where T154:struct,IDataType where T155:struct,IDataType where T156:struct,IDataType where T157:struct,IDataType where T158:struct,IDataType where T159:struct,IDataType where T160:struct,IDataType where T161:struct,IDataType where T162:struct,IDataType where T163:struct,IDataType where T164:struct,IDataType where T165:struct,IDataType where T166:struct,IDataType where T167:struct,IDataType where T168:struct,IDataType where T169:struct,IDataType where T170:struct,IDataType where T171:struct,IDataType where T172:struct,IDataType where T173:struct,IDataType where T174:struct,IDataType where T175:struct,IDataType where T176:struct,IDataType where T177:struct,IDataType where T178:struct,IDataType where T179:struct,IDataType where T180:struct,IDataType where T181:struct,IDataType where T182:struct,IDataType where T183:struct,IDataType where T184:struct,IDataType where T185:struct,IDataType where T186:struct,IDataType where T187:struct,IDataType where T188:struct,IDataType where T189:struct,IDataType where T190:struct,IDataType where T191:struct,IDataType where T192:struct,IDataType where T193:struct,IDataType where T194:struct,IDataType where T195:struct,IDataType where T196:struct,IDataType where T197:struct,IDataType where T198:struct,IDataType where T199:struct,IDataType where T200:struct,IDataType where T201:struct,IDataType where T202:struct,IDataType where T203:struct,IDataType where T204:struct,IDataType where T205:struct,IDataType where T206:struct,IDataType where T207:struct,IDataType where T208:struct,IDataType where T209:struct,IDataType where T210:struct,IDataType where T211:struct,IDataType where T212:struct,IDataType where T213:struct,IDataType where T214:struct,IDataType where T215:struct,IDataType where T216:struct,IDataType where T217:struct,IDataType where T218:struct,IDataType where T219:struct,IDataType where T220:struct,IDataType where T221:struct,IDataType where T222:struct,IDataType where T223:struct,IDataType where T224:struct,IDataType where T225:struct,IDataType where T226:struct,IDataType where T227:struct,IDataType where T228:struct,IDataType where T229:struct,IDataType where T230:struct,IDataType where T231:struct,IDataType where T232:struct,IDataType where T233:struct,IDataType where T234:struct,IDataType where T235:struct,IDataType where T236:struct,IDataType where T237:struct,IDataType where T238:struct,IDataType where T239:struct,IDataType where T240:struct,IDataType where T241:struct,IDataType where T242:struct,IDataType where T243:struct,IDataType where T244:struct,IDataType where T245:struct,IDataType where T246:struct,IDataType where T247:struct,IDataType where T248:struct,IDataType where T249:struct,IDataType where T250:struct,IDataType where T251:struct,IDataType where T252:struct,IDataType where T253:struct,IDataType where T254:struct,IDataType where T255:struct,IDataType{public BulkWriter()=>throw new InvalidOperationException("Parameterless constructor is not allowed to be called!");BulkWriter(UserTable table,Maybe<ErrorTable>errTable,Prod<ulong,double>maxErrorsAllowed,string processName,string userName,bool encrypted,bool encryptedMod)=>(Destination,ErrTable,MaxErrorsAllowed,_currentErrorCount,_currentProcessedCount,_processName,_userName,_containsEncryptedColumn,_mustBeAllowEncryptedValueModifications)=(table,errTable,maxErrorsAllowed,ulong.MinValue,ulong.MinValue,processName,userName,encrypted,encryptedMod);public readonly Maybe<ErrorTable>ErrTable;public readonly UserTable Destination;public readonly Prod<ulong,double>MaxErrorsAllowed;ulong _currentErrorCount;ulong _currentProcessedCount;readonly string _processName;readonly string _userName;readonly bool _containsEncryptedColumn;readonly bool _mustBeAllowEncryptedValueModifications;readonly Maybe<ErrorTable>IBulkWriter.ErrTable=>ErrTable;readonly UserTable IBulkWriter.Destination=>Destination;readonly Prod<ulong,double>IBulkWriter.MaxErrorsAllowed=>MaxErrorsAllowed;public readonly ulong CurrentSuccessfullyProcessedCount=>_currentProcessedCount-_currentErrorCount;public readonly ulong CurrentErrorCount=>_currentErrorCount;public readonly ulong CurrentProcessedCount=>_currentProcessedCount;public readonly double CurrentErrorRatio=>(double)_currentErrorCount/_currentProcessedCount;public readonly bool IsInError=>_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1;public static Result<BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>,BulkWriterCreateError>New(in UserTable table,Prod<ulong,double>maxErrorsAllowed,in Maybe<ErrorTable>errTable,string processName,string userName){if(table.Schema.Database.IsReadOnly){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.DatabaseIsReadOnly,new StackTrace(1,true)));}else if(double.IsNaN(maxErrorsAllowed.Item1)||double.IsNegative(maxErrorsAllowed.Item1)||maxErrorsAllowed.Item1>1.0d){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.InvalidErrorRatio,new StackTrace(1,true)));}else if(processName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.ProcessNameLengthExceeds128,new StackTrace(1,true)));}else if(userName.Length>128){return new(new BulkWriterCreateError(BulkWriterCreateError.Tag.UserNameLengthExceeds128,new StackTrace(1,true)));}else{var counter=ushort.MinValue;var match=TypeMatch(Std.Iter.Functions.FromFn(()=>counter++switch{0=>new(typeof(T0)),1=>new(typeof(T1)),2=>new(typeof(T2)),3=>new(typeof(T3)),4=>new(typeof(T4)),5=>new(typeof(T5)),6=>new(typeof(T6)),7=>new(typeof(T7)),8=>new(typeof(T8)),9=>new(typeof(T9)),10=>new(typeof(T10)),11=>new(typeof(T11)),12=>new(typeof(T12)),13=>new(typeof(T13)),14=>new(typeof(T14)),15=>new(typeof(T15)),16=>new(typeof(T16)),17=>new(typeof(T17)),18=>new(typeof(T18)),19=>new(typeof(T19)),20=>new(typeof(T20)),21=>new(typeof(T21)),22=>new(typeof(T22)),23=>new(typeof(T23)),24=>new(typeof(T24)),25=>new(typeof(T25)),26=>new(typeof(T26)),27=>new(typeof(T27)),28=>new(typeof(T28)),29=>new(typeof(T29)),30=>new(typeof(T30)),31=>new(typeof(T31)),32=>new(typeof(T32)),33=>new(typeof(T33)),34=>new(typeof(T34)),35=>new(typeof(T35)),36=>new(typeof(T36)),37=>new(typeof(T37)),38=>new(typeof(T38)),39=>new(typeof(T39)),40=>new(typeof(T40)),41=>new(typeof(T41)),42=>new(typeof(T42)),43=>new(typeof(T43)),44=>new(typeof(T44)),45=>new(typeof(T45)),46=>new(typeof(T46)),47=>new(typeof(T47)),48=>new(typeof(T48)),49=>new(typeof(T49)),50=>new(typeof(T50)),51=>new(typeof(T51)),52=>new(typeof(T52)),53=>new(typeof(T53)),54=>new(typeof(T54)),55=>new(typeof(T55)),56=>new(typeof(T56)),57=>new(typeof(T57)),58=>new(typeof(T58)),59=>new(typeof(T59)),60=>new(typeof(T60)),61=>new(typeof(T61)),62=>new(typeof(T62)),63=>new(typeof(T63)),64=>new(typeof(T64)),65=>new(typeof(T65)),66=>new(typeof(T66)),67=>new(typeof(T67)),68=>new(typeof(T68)),69=>new(typeof(T69)),70=>new(typeof(T70)),71=>new(typeof(T71)),72=>new(typeof(T72)),73=>new(typeof(T73)),74=>new(typeof(T74)),75=>new(typeof(T75)),76=>new(typeof(T76)),77=>new(typeof(T77)),78=>new(typeof(T78)),79=>new(typeof(T79)),80=>new(typeof(T80)),81=>new(typeof(T81)),82=>new(typeof(T82)),83=>new(typeof(T83)),84=>new(typeof(T84)),85=>new(typeof(T85)),86=>new(typeof(T86)),87=>new(typeof(T87)),88=>new(typeof(T88)),89=>new(typeof(T89)),90=>new(typeof(T90)),91=>new(typeof(T91)),92=>new(typeof(T92)),93=>new(typeof(T93)),94=>new(typeof(T94)),95=>new(typeof(T95)),96=>new(typeof(T96)),97=>new(typeof(T97)),98=>new(typeof(T98)),99=>new(typeof(T99)),100=>new(typeof(T100)),101=>new(typeof(T101)),102=>new(typeof(T102)),103=>new(typeof(T103)),104=>new(typeof(T104)),105=>new(typeof(T105)),106=>new(typeof(T106)),107=>new(typeof(T107)),108=>new(typeof(T108)),109=>new(typeof(T109)),110=>new(typeof(T110)),111=>new(typeof(T111)),112=>new(typeof(T112)),113=>new(typeof(T113)),114=>new(typeof(T114)),115=>new(typeof(T115)),116=>new(typeof(T116)),117=>new(typeof(T117)),118=>new(typeof(T118)),119=>new(typeof(T119)),120=>new(typeof(T120)),121=>new(typeof(T121)),122=>new(typeof(T122)),123=>new(typeof(T123)),124=>new(typeof(T124)),125=>new(typeof(T125)),126=>new(typeof(T126)),127=>new(typeof(T127)),128=>new(typeof(T128)),129=>new(typeof(T129)),130=>new(typeof(T130)),131=>new(typeof(T131)),132=>new(typeof(T132)),133=>new(typeof(T133)),134=>new(typeof(T134)),135=>new(typeof(T135)),136=>new(typeof(T136)),137=>new(typeof(T137)),138=>new(typeof(T138)),139=>new(typeof(T139)),140=>new(typeof(T140)),141=>new(typeof(T141)),142=>new(typeof(T142)),143=>new(typeof(T143)),144=>new(typeof(T144)),145=>new(typeof(T145)),146=>new(typeof(T146)),147=>new(typeof(T147)),148=>new(typeof(T148)),149=>new(typeof(T149)),150=>new(typeof(T150)),151=>new(typeof(T151)),152=>new(typeof(T152)),153=>new(typeof(T153)),154=>new(typeof(T154)),155=>new(typeof(T155)),156=>new(typeof(T156)),157=>new(typeof(T157)),158=>new(typeof(T158)),159=>new(typeof(T159)),160=>new(typeof(T160)),161=>new(typeof(T161)),162=>new(typeof(T162)),163=>new(typeof(T163)),164=>new(typeof(T164)),165=>new(typeof(T165)),166=>new(typeof(T166)),167=>new(typeof(T167)),168=>new(typeof(T168)),169=>new(typeof(T169)),170=>new(typeof(T170)),171=>new(typeof(T171)),172=>new(typeof(T172)),173=>new(typeof(T173)),174=>new(typeof(T174)),175=>new(typeof(T175)),176=>new(typeof(T176)),177=>new(typeof(T177)),178=>new(typeof(T178)),179=>new(typeof(T179)),180=>new(typeof(T180)),181=>new(typeof(T181)),182=>new(typeof(T182)),183=>new(typeof(T183)),184=>new(typeof(T184)),185=>new(typeof(T185)),186=>new(typeof(T186)),187=>new(typeof(T187)),188=>new(typeof(T188)),189=>new(typeof(T189)),190=>new(typeof(T190)),191=>new(typeof(T191)),192=>new(typeof(T192)),193=>new(typeof(T193)),194=>new(typeof(T194)),195=>new(typeof(T195)),196=>new(typeof(T196)),197=>new(typeof(T197)),198=>new(typeof(T198)),199=>new(typeof(T199)),200=>new(typeof(T200)),201=>new(typeof(T201)),202=>new(typeof(T202)),203=>new(typeof(T203)),204=>new(typeof(T204)),205=>new(typeof(T205)),206=>new(typeof(T206)),207=>new(typeof(T207)),208=>new(typeof(T208)),209=>new(typeof(T209)),210=>new(typeof(T210)),211=>new(typeof(T211)),212=>new(typeof(T212)),213=>new(typeof(T213)),214=>new(typeof(T214)),215=>new(typeof(T215)),216=>new(typeof(T216)),217=>new(typeof(T217)),218=>new(typeof(T218)),219=>new(typeof(T219)),220=>new(typeof(T220)),221=>new(typeof(T221)),222=>new(typeof(T222)),223=>new(typeof(T223)),224=>new(typeof(T224)),225=>new(typeof(T225)),226=>new(typeof(T226)),227=>new(typeof(T227)),228=>new(typeof(T228)),229=>new(typeof(T229)),230=>new(typeof(T230)),231=>new(typeof(T231)),232=>new(typeof(T232)),233=>new(typeof(T233)),234=>new(typeof(T234)),235=>new(typeof(T235)),236=>new(typeof(T236)),237=>new(typeof(T237)),238=>new(typeof(T238)),239=>new(typeof(T239)),240=>new(typeof(T240)),241=>new(typeof(T241)),242=>new(typeof(T242)),243=>new(typeof(T243)),244=>new(typeof(T244)),245=>new(typeof(T245)),246=>new(typeof(T246)),247=>new(typeof(T247)),248=>new(typeof(T248)),249=>new(typeof(T249)),250=>new(typeof(T250)),251=>new(typeof(T251)),252=>new(typeof(T252)),253=>new(typeof(T253)),254=>new(typeof(T254)),255=>new(typeof(T255)),_=>Maybe<Type>.None()}),in table);return match.IsSome?match.Unwrap()?new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>(table,errTable,maxErrorsAllowed,processName,userName,table.ContainsEncryptedColumn(),false)):new(new BulkWriterCreateError(BulkWriterCreateError.Tag.TypeMismatch,new StackTrace(1,true))):new(new BulkWriter<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>(table,errTable,maxErrorsAllowed,processName,userName,true,true));}}public override readonly bool Equals(object?_)=>false;public override readonly int GetHashCode()=>0;readonly void IBulkWriter.Sealed(){}public override readonly string ToString()=>string.Empty;public Result<Unit,WriteError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SessionOptions options)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{var allowEncryptMod=false;if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){allowEncryptMod=true;}else{return new(new WriteError(WriteError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteError(WriteError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}using var con=Functions.CreateOpenedConnection(in Destination.Schema.Database,options,!allowEncryptMod&&_containsEncryptedColumn,Maybe<Uri>.None());if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){using var txn=con.BeginTransaction(IsolationLevel.Serializable);using (SqlCommand qry=new($"SET IDENTITY_INSERT [{Destination.Schema.Name.Value}].[{Destination.Name}] ON;",con,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=60,CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){_=qry.ExecuteNonQuery();}txn.Commit();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,null,(options&SessionOptions.NUMERIC_ROUNDABORT_OFF)!=SessionOptions.NUMERIC_ROUNDABORT_OFF,new StackTrace(1,true).ToString()).MapErr(_writeTxnErrToWriteErr);}public Result<Unit,WriteErrorOrTransactionError>Write<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlTransaction txn)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(txn.Connection.State!=ConnectionState.Open){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionIsNotOpen,new StackTrace(1,true)));}else if(!string.Equals(txn.Connection.DataSource,$"tcp:{Destination.Schema.Database.Server.IntoString()}",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionServerMismatch,new StackTrace(1,true)));}else{if((writeOptions&WriteOptions.AllowEncryptedValueModifications)==WriteOptions.AllowEncryptedValueModifications){if(_containsEncryptedColumn){if(!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.SqlConnectionViolatesAllowEncryptedValueModifications,new StackTrace(1,true)));}}else{return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableExpectedToContainEncryptedDataButDoesNot,new StackTrace(1,true)));}}else if(_mustBeAllowEncryptedValueModifications){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.TableColumnMismatchOrWriteOptionsMustContainAllowEncryptedValueModifications,new StackTrace(1,true)));}else if(_containsEncryptedColumn&&!txn.Connection.ConnectionString.Contains("Column Encryption Setting=enabled",StringComparison.Ordinal)){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.ContainsEncryptedColumnsButConnectionDoesNotHandleEncryptedColumns,new StackTrace(1,true)));}if((writeOptions&WriteOptions.KeepIdentity)==WriteOptions.KeepIdentity&&Destination.ContainsIDENTITYColumn()){bool numericRoundAbort;using (SqlCommand qry=new($@"SET IDENTITY_INSERT [{Destination.Schema.Database.Name.Value}].[{Destination.Schema.Name.Value}].[{Destination.Name}] ON;SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}var tableCopy=Destination;return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString()).MapOrElse((err)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};_=qry.ExecuteNonQuery();return new Result<Unit,WriteErrorOrTransactionError>(err);},(x)=>{using SqlCommand qry=new($"SET IDENTITY_INSERT [{tableCopy.Schema.Database.Name.Value}].[{tableCopy.Schema.Name.Value}].[{tableCopy.Name}] OFF;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true};var unused=qry.ExecuteNonQuery();return new(x);});}else{bool numericRoundAbort;using (SqlCommand qry=new($@"SELECT CASE (@@OPTIONS & 8192) WHEN 8192 THEN CONVERT(bit,1) ELSE CONVERT(bit,0) END AS fblnNumericRoundabort;",txn.Connection,txn,SqlCommandColumnEncryptionSetting.Disabled){CommandTimeout=timeout.MapOr(0,_nzUshortToInt),CommandType=CommandType.Text,EnableOptimizedParameterBinding=true}){numericRoundAbort=(bool)qry.ExecuteScalar();}return WriteInternal<TRowIter,TRow,TProd,TErr>(ref iter,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,txn.Connection,txn,numericRoundAbort,new StackTrace(1,true).ToString());}}}Result<Unit,WriteErrorOrTransactionError>WriteInternal<TRowIter,TRow,TProd,TErr>(ref TRowIter iter,WriteOptions writeOptions,Maybe<NonZeroUshort>batchSize,Maybe<NonZeroUshort>timeout,bool enableStreaming,bool isSortedAccordingToClusteredIndex,SqlConnection con,SqlTransaction?txn,bool numericRoundAbort,string stackTrace)where TErr:notnull,IBulkRowError where TProd:notnull,IBinSerializable,IProduct<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>where TRow:notnull,ISum<TProd,TErr>where TRowIter:notnull,IFusedIterator<TRow>{if(_currentErrorCount>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1){return new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true)));}using var blk=CreateBulkCopy(in Destination,writeOptions,batchSize,timeout,enableStreaming,isSortedAccordingToClusteredIndex,con,txn);using IterDataReader<TRowIter,TRow,TProd,TErr,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20,T21,T22,T23,T24,T25,T26,T27,T28,T29,T30,T31,T32,T33,T34,T35,T36,T37,T38,T39,T40,T41,T42,T43,T44,T45,T46,T47,T48,T49,T50,T51,T52,T53,T54,T55,T56,T57,T58,T59,T60,T61,T62,T63,T64,T65,T66,T67,T68,T69,T70,T71,T72,T73,T74,T75,T76,T77,T78,T79,T80,T81,T82,T83,T84,T85,T86,T87,T88,T89,T90,T91,T92,T93,T94,T95,T96,T97,T98,T99,T100,T101,T102,T103,T104,T105,T106,T107,T108,T109,T110,T111,T112,T113,T114,T115,T116,T117,T118,T119,T120,T121,T122,T123,T124,T125,T126,T127,T128,T129,T130,T131,T132,T133,T134,T135,T136,T137,T138,T139,T140,T141,T142,T143,T144,T145,T146,T147,T148,T149,T150,T151,T152,T153,T154,T155,T156,T157,T158,T159,T160,T161,T162,T163,T164,T165,T166,T167,T168,T169,T170,T171,T172,T173,T174,T175,T176,T177,T178,T179,T180,T181,T182,T183,T184,T185,T186,T187,T188,T189,T190,T191,T192,T193,T194,T195,T196,T197,T198,T199,T200,T201,T202,T203,T204,T205,T206,T207,T208,T209,T210,T211,T212,T213,T214,T215,T216,T217,T218,T219,T220,T221,T222,T223,T224,T225,T226,T227,T228,T229,T230,T231,T232,T233,T234,T235,T236,T237,T238,T239,T240,T241,T242,T243,T244,T245,T246,T247,T248,T249,T250,T251,T252,T253,T254,T255>rdr=new(ErrTable,Destination,MaxErrorsAllowed,_currentProcessedCount,_currentErrorCount,iter,_processName,_userName,numericRoundAbort,stackTrace);blk.WriteToServer(rdr);_currentProcessedCount=rdr.CurrentProcessedCount;return (_currentErrorCount=rdr.CurrentErrorCount)>MaxErrorsAllowed.Item0&&CurrentErrorRatio>MaxErrorsAllowed.Item1?new(new WriteErrorOrTransactionError(WriteErrorOrTransactionError.Tag.MaxErrorsExceeded,new StackTrace(1,true))):new(new Unit());}}
    145 }