public static void MigrateReports(ElectronicStoresSystemDbContext storeContext)
        {
            var mySqlContext = new ElectronicStoreMySQLFluentModel();

            var reports = storeContext.Sales.OrderBy(s => s.Store.StoreName).ToList();

            for (int i = 1, len = reports.Count; i < len; i++)
            {
                var newReport = new Report
                {
                    ReportId = i,
                    Price = reports[i].Price,
                    ProductName = reports[i].Product.ProductName,
                    Quantity = reports[i].Quantity,
                    StoreName = reports[i].Store.StoreName,
                    Sum = reports[i].Sum,
                };

                using (var ctx = new ElectronicStoreMySQLFluentModel())
                {
                    ctx.Add(newReport);
                    ctx.SaveChanges();
                }
            }
        }
        public static void SaveReport(Report report)
        {
            var ctx = new ElectronicStoreMySQLFluentModel();

            using (ctx)
            {
                ctx.Add(report);
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 private static void createNode(Report report, XmlTextWriter writer)
 {
     writer.WriteStartElement("Product");
     writer.WriteStartElement("Report-id");
     writer.WriteString(report.ReportId.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("Product-Name");
     writer.WriteString(report.ProductName);
     writer.WriteEndElement();
     writer.WriteStartElement("Store-Name");
     writer.WriteString(report.StoreName);
     writer.WriteEndElement();
     writer.WriteStartElement("Quantity");
     writer.WriteString(report.Quantity.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("Price");
     writer.WriteString(report.Price.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("Sum");
     writer.WriteString(report.Sum.ToString());
     writer.WriteEndElement();
     writer.WriteEndElement();
 }