当前位置: 首页>>代码示例>>C#>>正文


C# DocumentContext.EnsureDatabaseExists方法代码示例

本文整理汇总了C#中DocumentContext.EnsureDatabaseExists方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentContext.EnsureDatabaseExists方法的具体用法?C# DocumentContext.EnsureDatabaseExists怎么用?C# DocumentContext.EnsureDatabaseExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentContext的用法示例。


在下文中一共展示了DocumentContext.EnsureDatabaseExists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            var ctx = new DocumentContext("main");
            ctx.EnsureDatabaseExists();

            //var untyped = ctx.GetCollection("Customer");
            //dynamic c = new ExpandoObject();
            //c.Name = "Dynamic";
            //c.Address = new Address { Line1 = "a", ZipCode = "123", City = "b" };
            //c.Id = Guid.NewGuid();

            //untyped.Add(c);

            //var query = (
            //    from order in ctx.GetCollection<Order>().AsQueryable()
            //    where order.OrderTotal > 0
            //    //  where order.OrderDate < DateTime.Now
            //    where order.Status == OrderStatus.Shipped
            //    select order
            //    );

            ////touch the db
            //var x = query.Take(1).ToList();

            //Stopwatch sw = new Stopwatch();
            //Console.WriteLine("Starting...");
            //sw.Start();
            //var result = query.ToList();
            //sw.Stop();

            //Console.WriteLine("feteched {0} records", result.Count);
            ////foreach (var order in result)
            ////{
            ////    Console.WriteLine("{0}", order);
            ////}

            //Console.WriteLine(sw.Elapsed);
            //Console.ReadLine();
            //return;

            Stopwatch sw = new Stopwatch();
            Console.WriteLine("Starting...");
            sw.Start();
            for (int i = 0; i < 5000; i++)
            {
                //Console.WriteLine(i);
                var someCompany = new Customer
                                  {
                                      Address = new Address
                                                    {
                                                        City = "Stora mellösa",
                                                        Line1 = "Linfrövägen " + i,
                                                        State = "T",
                                                        ZipCode = "71572"
                                                    },
                                      Name = "Precio" + i,

                                  };

                ctx.GetCollection<Customer>().Add(someCompany);

                //var someOrder = new Order
                //                       {
                //                           CustomerId = Guid.NewGuid(),
                //                           OrderDate = DateTime.Now,
                //                           ShippingDate = DateTime.Now,
                //                           OrderDetails = new List<OrderDetail>() ,
                //                           ShippingAddress = new Address
                //                                                 {
                //                                                     City = "a",
                //                                                     Line1 = "b",
                //                                                     ZipCode = "c"
                //                                                 },
                //                           Status = OrderStatus.Shipped,
                //                       };
                //for (int j = 0; j < 1; j++)
                //{
                //    someOrder.OrderDetails.Add(new OrderDetail
                //    {
                //        ItemPrice = i,
                //        ProductNo = "x" + i,
                //        Quantity = i,
                //    });
                //}

                //ctx.GetCollection<Order>().Add(someOrder);
                ////var result = DocumentSerializer.Serialize(specialOrder);
                ////Console.WriteLine(result.ToString());
                ////ctx.GetCollection<Order>().Add(specialOrder);
                ////ctx.SaveChanges();
                ////var des = DocumentDeserializer.Deserialize(result);

                ////    var address = new Address()
                ////                      {
                ////                          City = "Örebro",
                ////                          Line1 = "blabla",
                ////                          ZipCode = "" + i ,
                ////                      };

                ////    ctx.GetCollection<Address>().Add(address);
//.........这里部分代码省略.........
开发者ID:rogeralsing,项目名称:linq-to-sqlxml,代码行数:101,代码来源:Program.cs


注:本文中的DocumentContext.EnsureDatabaseExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。