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


C# MongoRepository.Save方法代码示例

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


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

示例1: TestInsert

 public void TestInsert()
 {
     var t = new Team {Name = "Test"};
     var repo = new MongoRepository<Team>(_db);
     repo.Save(t);
     Assert.NotNull(t.Id);
 }
开发者ID:etiennefab4,项目名称:PetanqueMVC,代码行数:7,代码来源:TestMongoDB.cs

示例2: TestRepository

        public void TestRepository()
        {
            var teams = new List<Team> { new Team("Tom", false, 1), new Team("Olive", false, 2) };
            var repo = new MongoRepository<Team>(_db);
            foreach (var t in teams)
            {
                repo.Save(t);
            }

            var teamsRefresh = repo.QueryAll();

            Assert.AreEqual(2 , teamsRefresh.Count());
        }
开发者ID:etiennefab4,项目名称:PetanqueMVC,代码行数:13,代码来源:TestMongoDB.cs

示例3: Main

        static void Main(string[] args)
        {
            var personReadModel = new MongoRepository<PersonDTO>("mongodb://localhost", "DDD_Light_MongoEventStore_Example", "Person_ReadModel");
            EventStore.Instance.Configure(new MongoRepository<AggregateEvent>("mongodb://localhost", "DDD_Light_MongoEventStore_Example", "EventStore"), new JsonEventSerializationStrategy());
            EventBus.Instance.Configure(EventStore.Instance, new JsonEventSerializationStrategy(), false);

            EventBus.Instance.Subscribe((PersonCreated personCreated) =>
                {                    
                    var personDTO = new PersonDTO {Id = personCreated.Id};
                    personReadModel.Save(personDTO);
                });
            
            EventBus.Instance.Subscribe((PersonNamed personNamed) =>
                {                    
                    var personDTO = personReadModel.GetById(personNamed.PersonId);
                    personDTO.Name = personNamed.Name;
                    personDTO.WasRenamed = false;
                    personReadModel.Save(personDTO);
                });

            EventBus.Instance.Subscribe((PersonRenamed personRenamed) =>
                {                    
                    var personDTO = personReadModel.GetById(personRenamed.PersonId);
                    personDTO.Name = personRenamed.Name;                    
                    personDTO.WasRenamed = true;                    
                    personReadModel.Save(personDTO);
                });


            NamePerson(personReadModel);
            NameAndRenamePerson(personReadModel);

            // Drop readmodel on mongo and then run this to restore
            //EventBus.Instance.RestoreReadModel(EventBus.Instance);


            Console.ReadLine();
        }
开发者ID:jango2015,项目名称:DDD.Light,代码行数:38,代码来源:Program.cs

示例4: TestGetById

        public void TestGetById()
        {
            var repo = new MongoRepository<Team>(_db);
            var team = new Team()
            {
                Name = "Tom"
            };
            repo.Save(team);
            var id = team.Id;

            var teamRefresh = repo.Find(id);

            Assert.AreEqual(teamRefresh.Name, "Tom");
        }
开发者ID:etiennefab4,项目名称:PetanqueMVC,代码行数:14,代码来源:TestMongoDB.cs

示例5: Save_IfHaveTheSameRecord_ReturnNull

 public void Save_IfHaveTheSameRecord_ReturnNull()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     repository.Insert(new TestModel { StringValue = "sinan" });
     item.StringValue = "sinan";
     var res3 = repository.Save(item);
     Assert.IsNull(res3);
 }
开发者ID:aderman,项目名称:Doco,代码行数:11,代码来源:MongoRepositoryTests.cs

示例6: Save_IfDontHaveTheSameRecord_ReturnItem

 public void Save_IfDontHaveTheSameRecord_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     var res = repository.Insert(item);
     item.StringValue2 = "sinan";
     var res2 = repository.Save(item);
     Assert.IsNotNull(res2);
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例7: SaveRoom

 public static bool SaveRoom(Room room)
 {
     if (VerifyRoom(room))
     {
         var mongoRepository = new MongoRepository<Room>(ConnectionString);
         mongoRepository.Save(room);
         return true;
     }
     return false;
 }
开发者ID:michaelbreyes,项目名称:Gabby,代码行数:10,代码来源:DatabaseManager.cs


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