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


C# Session.Drop方法代码示例

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


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

示例1: DbRefMapsToOtherDocumentsByOid

        public void DbRefMapsToOtherDocumentsByOid()
        {
            const string databaseName = "NormTests";
            var id = ObjectId.NewObjectId();

            using (var session = new Session())
            {
                session.Drop<Product>();
                session.Drop<ProductReference>();

                session.Add(new Product { _id = id, Name = "RefProduct" });

                var productReference = new DbReference<Product>(id);

                session.Add(new ProductReference
                    {
                        Id = ObjectId.NewObjectId(),
                        Name = "FullCart",
                        ProductsOrdered = new[] { productReference }
                    });
            }

            var server = Mongo.Create("mongodb://localhost/" + databaseName);
            var reference = server.GetCollection<ProductReference>().Find().First();
            var product = reference.ProductsOrdered[0].Fetch(() => server);

            Assert.Equal(id.Value, product._id.Value);
        }
开发者ID:perikete,项目名称:NoRM,代码行数:28,代码来源:DBRefTests.cs

示例2: DbRefMapsToOtherDocumentsByCustomId

        public void DbRefMapsToOtherDocumentsByCustomId()
        {
            const string databaseName = "NormTests";
            const string userId = "Tim Berners-Lee";
            const string roleName = "Administrator";

            using (var session = new Session())
            {
                session.Drop<User>();
                session.Drop<Role>();

                session.Add(new User
                                {
                                    Id = userId,
                                    EmailAddress = "[email protected]"
                                });
                session.Add(new Role
                                {
                                    Id = roleName,
                                    Users = new List<DbReference<User, string>>
                                                {
                                                    new DbReference<User, string>(userId)
                                                }
                                });
            }

            var server = Mongo.Create("mongodb://localhost/" + databaseName);
            var role = server.GetCollection<Role>().Find().First();
            var user = role.Users[0].Fetch(() => server);

            Assert.Equal(userId, user.Id);
        }
开发者ID:perikete,项目名称:NoRM,代码行数:32,代码来源:DBRefTests.cs

示例3: DBRefTests

 public DBRefTests()
 {
     using (var session = new Session())
     {
         session.Drop<Product>();
         session.Drop<ProductReference>();
     }
 }
开发者ID:kenegozi,项目名称:NoRM,代码行数:8,代码来源:DBRefTests.cs

示例4: LinqTests

 public LinqTests()
 {
     MongoConfiguration.RemoveMapFor<TestProduct>();
     MongoConfiguration.RemoveMapFor<Post>();
     using (var session = new Session())
     {
         session.Drop<TestProduct>();
         session.Drop<Post>();
     }
 }
开发者ID:StuartHarris,项目名称:NoRM,代码行数:10,代码来源:LinqTests.cs

示例5: LinqTests

 public LinqTests()
 {
     MongoConfiguration.RemoveMapFor<TestProduct>();
     MongoConfiguration.RemoveMapFor<Post>();
     using (var session = new Session())
     {
         session.Drop<TestProduct>();
         session.Drop<Post>();
     }
     using (var db = Mongo.Create(TestHelper.ConnectionString("strict=false")))
     {
         db.Database.DropCollection("acmePost");
     }
 }
开发者ID:mastoj,项目名称:NoRM,代码行数:14,代码来源:LinqTests.cs

示例6: MongoQueryExplainsExecutionPlansForFlyweightQueries

        public void MongoQueryExplainsExecutionPlansForFlyweightQueries()
        {
            using (var session = new Session())
            {
                session.Drop<TestProduct>();

                session.DB.GetCollection<TestProduct>().CreateIndex(p => p.Supplier.Name, "TestIndex", true, IndexOption.Ascending);

                session.Add(new TestProduct
                                {
                                    Name = "ExplainProduct",
                                    Price = 10,
                                    Supplier = new Supplier { Name = "Supplier", CreatedOn = DateTime.Now }
                                });

                // To see this manually you can run the following command in Mongo.exe against
                //the Product collection db.Product.ensureIndex({"Supplier.Name":1})

                // Then you can run this command to see a detailed explain plan
                // db.Product.find({"Supplier.Name":"abc"})

                // The following query is the same as running: db.Product.find({"Supplier.Name":"abc"}).explain()
                var query = new Expando();
                query["Supplier.Name"] = Q.Equals("Supplier");

                var result = session.DB.GetCollection<TestProduct>().Explain(query);

                Assert.Equal("BtreeCursor TestIndex", result.Cursor);
            }
        }
开发者ID:JornWildt,项目名称:NoRM,代码行数:30,代码来源:MongoOptimizationTests.cs

示例7: LinqTests

 public LinqTests()
 {
     using (var session = new Session())
     {
         session.Drop<Product>();
     }
 }
开发者ID:kenegozi,项目名称:NoRM,代码行数:7,代码来源:LinqTests.cs

示例8: LinqAggregates

 public LinqAggregates()
 {
     MongoConfiguration.RemoveMapFor<TestProduct>();
     using (var session = new Session())
     {
         session.Drop<TestProduct>();
     }
 }
开发者ID:ereichert,项目名称:NoRM,代码行数:8,代码来源:LinqAggregates.cs

示例9: LinqDeepGraph

 public LinqDeepGraph()
 {
     MongoConfiguration.RemoveMapFor<TestProduct>();
     MongoConfiguration.RemoveMapFor<Supplier>();
     MongoConfiguration.RemoveMapFor<InventoryChange>();
     MongoConfiguration.RemoveMapFor<Address>();
     using (var session = new Session())
     {
         session.Drop<TestProduct>();
     }
 }
开发者ID:ereichert,项目名称:NoRM,代码行数:11,代码来源:LinqDeepGraph.cs

示例10: OneProductShouldBeReturnedWhenNestedSupplierQueried

 public void OneProductShouldBeReturnedWhenNestedSupplierQueried()
 {
     using (var session = new Session())
     {
         session.Drop<Product>();
         session.Add(new Product {Name = "Test3", Price = 10, Supplier = new Supplier {Name = "Steve"}});
         session.Add(new Product {Name = "Test4", Price = 22});
         session.Add(new Product {Name = "Test5", Price = 33});
         var products = session.Products.Where(x => x.Supplier.Name == "Steve").ToList();
         Assert.Equal(1, products.Count);
     }
 }
开发者ID:kenegozi,项目名称:NoRM,代码行数:12,代码来源:LinqDeepGraph.cs

示例11: SupplierShouldBeQuerybleByAddressAndWorkWithOrExpression

 public void SupplierShouldBeQuerybleByAddressAndWorkWithOrExpression()
 {
     using (var session = new Session())
     {
         session.Drop<Product>();
         var add = new Address {State = "HI", Street = "100 Main"};
         session.Add(new Product {Name = "Test3", Price = 10, Supplier = new Supplier {Name = "Steve", CreatedOn = new DateTime(2000, 2, 1), Address = add}});
         session.Add(new Product {Name = "Test4", Price = 22, Supplier = new Supplier {Name = "Steve", CreatedOn = new DateTime(2001, 2, 1)}});
         session.Add(new Product {Name = "Test5", Price = 33, Supplier = new Supplier {Name = "Steve", CreatedOn = new DateTime(2002, 2, 1)}});
         var products = session.Products.Where(x => x.Supplier.Address.State == "HI" || x.Price == 33).ToList();
         Assert.Equal(2, products.Count);
     }
 }
开发者ID:kenegozi,项目名称:NoRM,代码行数:13,代码来源:LinqDeepGraph.cs

示例12: One_Product_Should_Be_Returned_When_Nested_Supplier_Queried

        public void One_Product_Should_Be_Returned_When_Nested_Supplier_Queried()
        {
            var session = new Session();
            session.Drop<Product>();

            session.Add(new Product() { Name = "Test3", Price = 10, Supplier = new Supplier() { Name = "Steve" } });
            session.Add(new Product() { Name = "Test4", Price = 22 });
            session.Add(new Product() { Name = "Test5", Price = 33 });

            var products = session.Products.Where(x => x.Supplier.Name == "Steve").ToList();

            Assert.AreEqual(1, products.Count);
        }
开发者ID:sdether,项目名称:NoRM,代码行数:13,代码来源:LinqDeepGraph.cs

示例13: Supplier_Should_Be_Queryble_By_Address_And_Work_With_Or_Expression

        public void Supplier_Should_Be_Queryble_By_Address_And_Work_With_Or_Expression()
        {
            var session = new Session();
            session.Drop<Product>();
            var add = new Address() { State = "HI", Street = "100 Main" };

            session.Add(new Product() { Name = "Test3", Price = 10, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2000, 2, 1), Address = add } });
            session.Add(new Product() { Name = "Test4", Price = 22, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2001, 2, 1) } });
            session.Add(new Product() { Name = "Test5", Price = 33, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2002, 2, 1) } });

            var products = session.Products.Where(x => x.Supplier.Address.State == "HI" || x.Price == 33).ToList();

            Assert.AreEqual(2, products.Count);
        }
开发者ID:sdether,项目名称:NoRM,代码行数:14,代码来源:LinqDeepGraph.cs

示例14: Supplier_Should_Be_Queryble_By_DateMath

        public void Supplier_Should_Be_Queryble_By_DateMath()
        {
            var session = new Session();
            session.Drop<Product>();
            var add = new Address() { State = "HI", Street = "100 Main" };

            session.Add(new Product() { Name = "Test3", Price = 10, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2000, 2, 1), Address = add } });
            session.Add(new Product() { Name = "Test4", Price = 22, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2001, 2, 1) } });
            session.Add(new Product() { Name = "Test5", Price = 33, Supplier = new Supplier() { Name = "Steve", CreatedOn = new DateTime(2002, 2, 1) } });

            var products = session.Products.Where(x => x.Supplier.CreatedOn.Year<2001).ToList();

            //this is returning all three for some reason...
            Assert.AreEqual(1, products.Count);
        }
开发者ID:sdether,项目名称:NoRM,代码行数:15,代码来源:LinqDeepGraph.cs

示例15: CanQueryAndReturnSubClassedObjects_EvenWhenAddedBySubClass

        public void CanQueryAndReturnSubClassedObjects_EvenWhenAddedBySubClass()
        {
            using (var session = new Session())
            {
                session.Drop<SuperClassObject>();

                session.Add(new SubClassedObject());

                var query = new MongoQuery<SuperClassObject>(session.Provider);

                var dtos = query.ToList();

                Assert.Equal(1, dtos.Count);
            }
        }
开发者ID:perikete,项目名称:NoRM,代码行数:15,代码来源:LinqTests.cs


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