本文整理汇总了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);
//.........这里部分代码省略.........