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


C# MongoRepository.Insert方法代码示例

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


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

示例1: AsQueryable_InserThreeItem_ReturnTwo

 public void AsQueryable_InserThreeItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "ali" });
     var list = repository.AsQueryable().Where(x => x.StringValue == "sinan");
     Assert.AreEqual(2, list.Count());
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例2: ExistsUniqueItem_OnlySelf_ReturnItem

 public void ExistsUniqueItem_OnlySelf_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = new TestModel { StringValue = "sinan" };
     var item2 = new TestModel { StringValue = "sinana" };
     var item3 = new TestModel { StringValue = "sinanx" };
     repository.Insert(item);
     repository.Insert(item2);
     var result = repository.ExistsUniqueItem(item3);
     Assert.IsFalse(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:12,代码来源:MongoRepositoryTests.cs

示例3: Drop_IfHaveCollection_ReturnTrue

 public void Drop_IfHaveCollection_ReturnTrue()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Insert(TestModel.CreateInstance());
     var result = repository.Drop();
     Assert.IsTrue(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:7,代码来源:MongoRepositoryTests.cs

示例4: ExistsUniqueItem_Own_ReturnItem

 public void ExistsUniqueItem_Own_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     item.IntValue = 5;
     var result = repository.ExistsUniqueItem(item);
     Assert.IsFalse(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            //test the MongoDB

            IRepository<Test> testRepo = new MongoRepository<Test>();

            var t = new Test();
            t.Name = "testMNG";
            testRepo.Insert(t);
        }
开发者ID:ccvetanska,项目名称:Authorization_App,代码行数:10,代码来源:Dashboard.aspx.cs

示例6: Append

        protected override void Append(LoggingEvent loggingEvent)
        {
            var newLog = new LogRecord
                             {
                                 Level =  GetLogLevel(loggingEvent.Level),
                                 LogTime = loggingEvent.TimeStamp,
                                 Logger = loggingEvent.LoggerName,
                                 Thread = loggingEvent.ThreadName,
                                 Message = loggingEvent.MessageObject.ToString(),
                                 Exception =  loggingEvent.GetExceptionString(),

                                 ClassName = loggingEvent.LocationInformation.ClassName,
                                 FileName = loggingEvent.LocationInformation.FileName,
                                 MethodName = loggingEvent.LocationInformation.MethodName,
                                 LineNumber = loggingEvent.LocationInformation.LineNumber,
                                 CallStack = loggingEvent.LocationInformation.StackFrames.Select(x => x.ToString())
                                                                             .Aggregate((a, b) => string.Format("{0}{1}{2}", a, Environment.NewLine, b))
                             };

            var repo = new MongoRepository<LogRecord>();
            repo.Insert(newLog);
        }
开发者ID:NightOwls,项目名称:Log4NetAnalyzer,代码行数:22,代码来源:MongoAppender.cs

示例7: ExistsUniqueItem_SelfAndWithOtherProperties_ReturnNull

 public void ExistsUniqueItem_SelfAndWithOtherProperties_ReturnNull()
 {
     var repository = new MongoRepository<TestModel3>();
     repository.Drop();
     var item = new TestModel3 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     var item2 = new TestModel3 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsTrue(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例8: 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

示例9: 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

示例10: Insert_IfHaveTheSameRecord_ReturnNull

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

示例11: GetItemsByQuery_InserThreeItem_ReturnTwo

 public void GetItemsByQuery_InserThreeItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "sinan" });
     repository.Insert(new TestModel4 { StringValue = "ali" });
     var list = repository.GetItemsByQuery(Query.EQ("StringValue", "sinan"));
     Assert.AreEqual(2, list.Count());
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例12: GetItemById_SendObjectId_ReturnItem

 public void GetItemById_SendObjectId_ReturnItem()
 {
     var repository = new MongoRepository<TestModel>();
     repository.Drop();
     var item = TestModel.CreateInstance();
     repository.Insert(item);
     var res = repository.GetItemById(item.Id);
     Assert.IsNotNull(res);
 }
开发者ID:aderman,项目名称:Doco,代码行数:9,代码来源:MongoRepositoryTests.cs

示例13: GetAll_InserTwoItem_ReturnTwo

 public void GetAll_InserTwoItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4());
     repository.Insert(new TestModel4());
     var list = repository.GetAll();
     Assert.AreEqual(2, list.Count());
 }
开发者ID:aderman,项目名称:Doco,代码行数:9,代码来源:MongoRepositoryTests.cs

示例14: ExistsUniqueItem_WithOutBsonUnique_ReturnItem

 public void ExistsUniqueItem_WithOutBsonUnique_ReturnItem()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     var item = new TestModel4 { StringValue = "sinan", StringValue2 = "akyazıcı", DateTimeValue = DateTime.Parse("01/01/1967") };
     var item2 = new TestModel4 { StringValue = "sinan", StringValue2 = "akyazıcıx", DateTimeValue = DateTime.Parse("02/01/1967") };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsFalse(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs

示例15: ExistsUniqueItem_WithOtherProperties_ReturnNull

 public void ExistsUniqueItem_WithOtherProperties_ReturnNull()
 {
     var repository = new MongoRepository<TestModel2>();
     repository.Drop();
     var item = new TestModel2 { StringValue = "sinan", StringValue2 = "akyazıcı", IntValue = 5 };
     var item2 = new TestModel2 { StringValue = "sinan", StringValue2 = "akyazıcı", IntValue = 5 };
     repository.Insert(item);
     var result = repository.ExistsUniqueItem(item2);
     Assert.IsTrue(result);
 }
开发者ID:aderman,项目名称:Doco,代码行数:10,代码来源:MongoRepositoryTests.cs


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