public static void Main()
        {
            MongoUow data = new MongoUow();

               // data.Messages.Insert(new Message { Text = "Hello world !", DateMessage = DateTime.Now });

            string id = "540b071c3af3f809c4c6678e";

            var findById = data.Messages.GetById(id);

            Console.WriteLine(findById.Text);

            //var linqOperating = data.Messages.GetAll().FirstOrDefault(x => x.Text == "Hello world !");

            //Console.WriteLine(linqOperating.DateMessage);

            //var update = Update<Message>.Set(x=> x.Text , "Good day!");

            //data.Messages.Update(id, update);

              //  data.Messages.Delete(id);
        }
Beispiel #2
0
        public static void Main()
        {
            MongoUow data = new MongoUow();

            // data.Messages.Insert(new Message { Text = "Hello world !", DateMessage = DateTime.Now });

            string id = "540b071c3af3f809c4c6678e";

            var findById = data.Messages.GetById(id);

            Console.WriteLine(findById.Text);

            //var linqOperating = data.Messages.GetAll().FirstOrDefault(x => x.Text == "Hello world !");

            //Console.WriteLine(linqOperating.DateMessage);

            //var update = Update<Message>.Set(x=> x.Text , "Good day!");

            //data.Messages.Update(id, update);

            //  data.Messages.Delete(id);
        }
        public static void UpendToMsSQL ()
        {
            UowData sqlData = new UowData();
            MongoUow mongoData = new MongoUow();

            //var measure = new Measure { MeasureName = "Spas" };

            var collections = mongoData.Measurs.GetAll();

            
            using (sqlData)
            {
                foreach (var item in collections)
                {
                    string name = item.MeasureName;
                    int measureId = item.MeasureId;

                    Console.WriteLine("Name is : {0} Id is : {1}", name, measureId);


                    var sqlMeasure = new Measure
                    {
                        MeasureName = name
                    };

                    sqlData.Measures.Add(sqlMeasure);

                    sqlData.SaveChanges();


                }

            }


        }