Esempio n. 1
0
        private static void Import(CremaDataTable dataTable, SerializationTable serializedTable)
        {
            dataTable.Tags         = serializedTable.Tags;
            dataTable.CategoryPath = serializedTable.CategoryPath;
            dataTable.TableName    = serializedTable.TableName;
            dataTable.Comment      = serializedTable.Comment;

            var columns = serializedTable.Columns.Where(item => item.Name != CremaSchema.__RelationID__ && item.Name != CremaSchema.__ParentID__);

            foreach (var item in columns)
            {
                var dataColumn = dataTable.Columns.Add(item.Name);
                Import(dataColumn, item);
            }

            foreach (var item in columns)
            {
                var dataColumn = dataTable.Columns[item.Name];
                dataColumn.IsKey = item.IsKey;
            }

            foreach (var item in columns)
            {
                var dataColumn = dataTable.Columns[item.Name];
                dataColumn.Unique = item.IsUnique;
            }
            dataTable.AcceptChanges();
        }
Esempio n. 2
0
        public static CremaDataTable Create(SerializationTable serializedTable, SerializationType[] serializedTypes)
        {
            if (serializedTypes == null)
            {
                throw new ArgumentNullException(nameof(serializedTypes));
            }

            var dataTable = new CremaDataTable();

            Import(dataTable, serializedTable);
            return(dataTable);
        }
Esempio n. 3
0
 private static void ImportRow(CremaDataTable dataTable, SerializationTable serializedTable)
 {
     dataTable.BeginLoad();
     foreach (var item in serializedTable.Rows)
     {
         if (dataTable.Parent == null)
         {
             var dataRow = dataTable.NewRow();
             ImportRow(dataRow, item, serializedTable.Columns);
             dataTable.Rows.Add(dataRow);
         }
         else
         {
             var parentRow = dataTable.Parent.Rows.First(i => i.RelationID == item.ParentID);
             var dataRow   = dataTable.NewRow(parentRow);
             ImportRow(dataRow, item, serializedTable.Columns);
             dataTable.Rows.Add(dataRow);
         }
     }
     dataTable.EndLoad();
 }
Esempio n. 4
0
 public static CremaDataTable Create(SerializationTable serializedTable)
 {
     return(Create(serializedTable, new SerializationType[] { }));
 }