Exemplo n.º 1
0
            /// <summary>
            /// Creates a temporary table that represents a collection of identifiers.
            /// </summary>
            /// <typeparam name="T">The type of the temp table field/ column.</typeparam>
            /// <param name="context">The database context in which to create the temporary table.</param>
            /// <param name="idColumnName">Identifier column name.</param>
            /// <param name="ids">The collection of identifiers.</param>
            /// <returns>The temporary table created.</returns>
            public static TempTable CreateScalarTempTable <T>(SqliteDatabaseContext context, string idColumnName, IEnumerable <T> ids)
            {
                int       tempTableId = context.GetNextContextIdentifier();
                DataTable table       = new DataTable(idColumnName + "TempTable" + tempTableId);

                table.Columns.Add(idColumnName, typeof(T));

                foreach (T id in ids)
                {
                    var row = table.NewRow();
                    row[idColumnName] = id;
                    table.Rows.Add(row);
                }

                return(context.CreateTemporaryTable(table));
            }