Example #1
0
        protected void btnShowData_Click(object sender, EventArgs e)
        {
            using (var ctx = new DemoContext())
            {
                XDocument doc =
              new XDocument(
            new XElement("file",
              new XElement("name", new XAttribute("filename", "sample")),
              new XElement("date", new XAttribute("modified", DateTime.Now)),
              new XElement("info",
            ctx.Data.ToList().Select(x => new XElement("data", new XAttribute("value", x.Content)))
              )
            )
              );

                //var doc = new XmlDocument();
                //var root = doc.CreateElement("Root");

                //ctx.Data.ToList().ForEach(line =>
                //{
                //	var node = doc.CreateElement("Data");
                //	node.Value = line.Content.Replace(Environment.NewLine, "").Replace("\r\n", "");
                //	root.AppendChild(node);
                //});
                //doc.AppendChild(root);

                doc.Save(@"c:\temp.xml");

                MyGridView.DataSource = ctx.Data.ToList();
                MyGridView.DataBind();
            }
        }
Example #2
0
        protected void btnSaveData_Click(object sender, EventArgs e)
        {
            var content = File.ReadAllText(@"C:/103578186.html");
            //var content = File.ReadAllText(@"C:/CM Team/102935761.html");
            var myList = GetContent(content);
            var count = 100;
            using (var ctx = new DemoContext())
            {

                myList.ToList().ForEach(c => ctx.Data.Add(new Data()
                {
                    DataId = count++,
                    Content = c
                }));

                ctx.SaveChanges();
            }
        }