Exemple #1
0
        /// <inheritdoc />
        public IInsertDataSyntax Row(IDictionary <string, object> data)
        {
            var dataDefinition = new InsertionDataDefinition();

            dataDefinition.AddRange(data);
            _expression.Rows.Add(dataDefinition);
            return(this);
        }
        public IInsertDataSyntax Row(IDictionary<string, object> data)
        {
            var dataDefinition = new InsertionDataDefinition();

            dataDefinition.AddRange(data);

            _expression.Rows.Add(dataDefinition);

            return this;
        }
Exemple #3
0
        /// <inheritdoc />
        public IMigrationExpression Reverse()
        {
            var expression = new InsertDataExpression {
                SchemaName = SchemaName,
                TableName  = TableName
            };

            foreach (var row in Rows)
            {
                var dataDefinition = new InsertionDataDefinition();
                dataDefinition.AddRange(row);
                expression.Rows.Add(dataDefinition);
            }
            return(expression);
        }
        public IMigrationExpression Reverse()
        {
            var expression = new InsertDataExpression
            {
                SchemaName = SchemaName,
                TableName = TableName
            };

            foreach (var row in Rows)
            {
                var dataDefinition = new InsertionDataDefinition();
                dataDefinition.AddRange(row);

                expression.Rows.Add(dataDefinition);
            }

            return expression;
        }
        private static IEnumerable<InsertionDataDefinition> GetData(string pathToDataTable)
        {
            var data = new List<InsertionDataDefinition>();

             if (!File.Exists(pathToDataTable))
            return data;

              var xsd = pathToDataTable.Replace(".xml", ".xsd");

              if (!File.Exists(xsd))
             return data;

             var dataSet = new DataSet();
              dataSet.ReadXmlSchema(xsd);
              dataSet.ReadXml(pathToDataTable);

              var dataAsDataTable = dataSet.Tables[0];

             foreach (DataRow dr in dataAsDataTable.Rows)
             {
            var dataRow = new InsertionDataDefinition();

            dataRow.AddRange(from DataColumn column in dataAsDataTable.Columns
                             select new KeyValuePair<string, object>(column.ColumnName, ((dr[column.ColumnName] is string) ? ((string)dr[column.ColumnName]).Trim() : dr[column.ColumnName])));
            data.Add(dataRow);
             }

             return data;
        }