コード例 #1
0
        /// <summary>
        /// Create a DataRecords table from a SQL file.
        /// </summary>
        /// <param name="inputProfile"></param>
        /// <param name="constraint">Optional constraint assembly, 
        ///     for linking this table to a master DataSet during its construction.</param>
        /// <param name="longName">A short name for this table -- if null, will be the name of the record class in the table's rows.</param>
        public FileDataRecords(
            IO_SQLIn inputProfile
            , ForeignKeyConstraintElements constraint = null
            , string longName = null)
        {
            this.longName = longName ?? string.Format(
                $"SQLIn_Table_{SampleBasicRecord.GetChildType().Name}_{IODirectory.PrepGuid}_{ctr}");
            string index = null;
            if (ctr > 0) { index = string.Format($"_{ctr}"); }
            this.TableName = string.Format($"{SampleBasicRecord.GetChildType().Name}{index}");

            DataTable table = new DataTable(TableName);
            table = SQL.ExecuteBuiltCommandReturnQuery(inputProfile.Query, table);
            ctr++;
            
            this.Merge(table);
            LinkTable_FK(constraint);
        }
コード例 #2
0
        /*****Constructors*****/

        /// <summary>
        /// A class to create a DataTable and link it to a DataSet, according to a constraint.
        /// </summary>
        /// <param name="source">Each Stringmap in the List of Stringmaps is a line of strings, with a string for a column.</param>
        /// <param name="sampleColumns">A dictionary of column types from the client-specific implementation classes.</param>
        /// <param name="constraint">Optional assembly of settings for foreign key constraints for this table, if any.</param>
        /// <param name="longName">A short name for this table -- if null, will be the name of the record class in the table's rows.
        /// <br>The List of strings after this is the headers.</br></param>
        public FileDataRecords(
            HeaderSource<List<StringMap>, List<string>> source
            , Dictionary<Type, TableHeaders> sampleColumns
            , ForeignKeyConstraintElements constraint = null
            , string longName = null) : base(typeof(TBasicRecord).Name)
        {
            columnInfo = sampleColumns[typeof(TBasicRecord)];
            unique = SampleBasicRecord.keyIsUniqueIdentifier;

            List<StringMap> dataList = source.data; // list of dictionaries of data strings, keyed by column strings
            List<string> headerStrings = source.headers;

            var src = new Dictionary<KeyStrings, TBasicRecord>();
            // TO DO: Analyze for parallelism
            foreach (StringMap strMap in dataList)
            {
                // Add a new Keystrings, record pair to the DataTable.
                TBasicRecord record = ((IRecord<TBasicRecord>)SampleBasicRecord).Record(
                        strMap
                        , columnInfo
                        , headerStrings);
                src.Add(
                    record.recordKey,
                    record
                    );
            }
            TableName = $"FilesIn_Table_{ typeof(TBasicRecord).Name}_{ IODirectory.PrepGuid}_{ctr}";

            this.longName = longName ?? string.Format(
                $"FilesIn_Table_{SampleBasicRecord.GetChildType().Name}_{IODirectory.PrepGuid}_{ctr}");
            string index = null;
            if (ctr > 0) { index = string.Format($"_{ctr}"); }
            this.TableName = string.Format($"{SampleBasicRecord.GetChildType().Name}{index}");

            SetColumns();
            SetRows(src);
            constraint.masterSet.Tables.Add(this);
            LinkTable_FK(constraint);
            
            ctr++; // TO DO: Needed or not?
        }
コード例 #3
0
 /*****Promises*****/
 /// <summary>
 /// Link a dataTable to another, according to a given constraint.
 /// </summary>
 /// <returns></returns>
 public void LinkTable_FK(
     ForeignKeyConstraintElements constraint = null)
 {
     constraint?.SetFKConstraint(this);
 }