示例#1
0
        /// <summary>
        /// Fills DataTable with simple text filter
        /// </summary>
        public void Fill(DataTable dataTable, string filter)
        {
            if (dataTable == null)
            {
                throw new ArgumentNullException("dataTable");
            }

            DbDataAdapter           dataAdapter = _providerFactory.CreateDataAdapter();
            DataTableCommandBuilder builder     = CreateCommandBuilder(dataTable, Connection);

            dataAdapter.SelectCommand = builder.GetSelectCommand(filter);
            dataAdapter.TableMappings.Add("Table", dataTable.TableName);
            dataAdapter.Fill(dataTable);
        }
示例#2
0
        /// <summary>
        /// Fills DataTable with filtered data. Parameters are passed
        /// using SqlParamater objects.
        /// </summary>
        public void Fill(DataTable dataTable, string filter, params object[] parameters)
        {
            if (dataTable == null)
            {
                throw new ArgumentNullException("dataTable");
            }

            DbDataAdapter           dataAdapter = _providerFactory.CreateDataAdapter();
            DataTableCommandBuilder builder     = CreateCommandBuilder(dataTable, Connection);

            dataAdapter.SelectCommand = builder.GetSelectCommand(filter);
            EnrollInTransaction(dataAdapter.SelectCommand);

            DataManager.AddParamsToCommand(dataAdapter.SelectCommand, SqlDialect, parameters);

            dataAdapter.TableMappings.Add("Table", dataTable.TableName);
            dataAdapter.Fill(dataTable);
        }