示例#1
0
        private static void CreateTableforRecord(DataSet dataset, IDataTableRecord record)
        {
            // TODO unit test
            var table = new DataTable(record.TableName);

            table.Columns.AddRange(CreateColumnsForRecord(record));
            dataset.Tables.Add(table);
        }
示例#2
0
        private static DataColumn[] CreateColumnsForRecord(IDataTableRecord record)
        {
            var collumns = new List <DataColumn>();

            foreach (var field in record.Fields)
            {
#pragma warning disable CC0022 // Should dispose object is not required for datacolumn but is an artifact of marshalbyref.
                var collumn = new DataColumn(field.Name, field.Type)
                {
                    DefaultValue = field.DefaultValue
                };
                collumns.Add(collumn);
#pragma warning restore CC0022 // Should dispose object
            }
            return(collumns.ToArray());
        }