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


C# IMongoCollection类代码示例

本文整理汇总了C#中IMongoCollection的典型用法代码示例。如果您正苦于以下问题:C# IMongoCollection类的具体用法?C# IMongoCollection怎么用?C# IMongoCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ApplicationIdentityContext

 private ApplicationIdentityContext(IMongoCollection<ApplicationUser> users, IMongoCollection<IdentityRole> roles, IMongoCollection<Client> clients, IMongoCollection<RefreshToken> refreshTokens)
 {
     Users = users;
     Roles = roles;
     Clients = clients;
     RefreshTokens = refreshTokens;
 }
开发者ID:DureSameen,项目名称:eTimeSheets.API,代码行数:7,代码来源:ApplicationIdentityContext.cs

示例2: ExpressionMethod

 private static Task ExpressionMethod(IMongoCollection<Person> col)
 {
     var filter = new ExpressionFilterDefinition<Person>(x => x.Id == "my id" && x.Name == "Jack");
     filter.Render(col.DocumentSerializer, col.Settings.SerializerRegistry);
     //await col.Find(x => x.Id == "my id" && x.Name == "Jack").ToListAsync();
     return Task.FromResult(true);
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:7,代码来源:FilterMeasuring.cs

示例3: SearchByName

        private static void SearchByName(IMongoCollection<EnergyDrink> collection)
        {
            Console.Clear();
            Console.Write("Enter the name:");
            var inputName = Console.ReadLine();

            var fileter = Builders<EnergyDrink>.Filter.Eq("Name", inputName);
            var result = collection.Find(fileter).ToListAsync().Result;

            if (result.Count == 0)
            {
                Console.WriteLine("\nThere are no drinks with name {0}", inputName);
            }

            else
            {
                foreach (var item in result)
                {
                    Console.WriteLine("Name: {0} => Price: {1}", item.Name, item.Price);
                }
            }

            Console.WriteLine("\nPress any key to continue..");
            Console.ReadLine();
        }
开发者ID:ni4ka7a,项目名称:TelerikAcademyHomeworks,代码行数:25,代码来源:EntryPoint.cs

示例4: ExecuteAsync

        public async Task<IEnumerable<Climb>> ExecuteAsync(GetClimbsQueryParameters parameters,
            IMongoCollection<Climb> collection)
        {
            var filters = new List<FilterDefinition<Climb>>();

            if (parameters.Id != Guid.Empty)
            {
                var filter = Builders<Climb>.Filter.Eq(c => c.Id == parameters.Id, true);

                filters.Add(filter);
            }

            if (parameters.Styles != null && parameters.Styles.Count > 0)
            {
                var filter = Builders<Climb>.Filter.AnyIn(c => c.Styles, parameters.Styles);
                filters.Add(filter);
            }

            if (!string.IsNullOrEmpty(parameters.Name))
            {
                var filter = Builders<Climb>.Filter.Eq(c => c.Name == parameters.Name, true);
                filters.Add(filter);
            }

            var complexFilter = Builders<Climb>.Filter.And(filters);

            var fullCollection = await collection.FindAsync(complexFilter);
            return await fullCollection.ToListAsync();
        }
开发者ID:MikeBeastall,项目名称:MonkeyStrong,代码行数:29,代码来源:GetClimbsQuery.cs

示例5: Querying

        public Querying()
        {
            client = new MongoClient(); ;
            database = client.GetDatabase("test");

            collection = database.GetCollection<Student>("Users");
        }
开发者ID:maximburyak,项目名称:TODA,代码行数:7,代码来源:Querying.cs

示例6: ChoiceRepository

 public ChoiceRepository()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:ChoiceController");
     _db = client.GetDatabase("patientcaredb");
     _choices = _db.GetCollection<BsonDocument>("Choice");
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:7,代码来源:ChoiceRepository.cs

示例7: UserStoreTests

		public UserStoreTests(string collectionPrefix)
		{
			collectionPrefix = $"{typeof(UserStoreTests).Name}_{collectionPrefix}";

			_databaseFixture = new DatabaseFixture(collectionPrefix);
			_userCollection = _databaseFixture.GetCollection<IdentityUser>();
			_roleCollection = _databaseFixture.GetCollection<IdentityRole>();
			_databaseContext = new IdentityDatabaseContext { UserCollection = _userCollection, RoleCollection = _roleCollection };

			_errorDescriber = new IdentityErrorDescriber();
			_userStore = new UserStore<IdentityUser, IdentityRole>(_databaseContext, null, _errorDescriber);


			_claim1 = new Claim("ClaimType1", "some value");
			_claim2 = new Claim("ClaimType2", "some other value");
			_claim3 = new Claim("other type", "some other value");

			_claim1SameType = new Claim(_claim1.Type, _claim1.Value + " different");

			_identityClaim1 = new IdentityClaim(_claim1);
			_identityClaim2 = new IdentityClaim(_claim2);
			_identityClaim3 = new IdentityClaim(_claim3);

			_identityClaim1SameType = new IdentityClaim(_claim1SameType);
		}
开发者ID:saan800,项目名称:SaanSoft.AspNet.Identity3.MongoDB,代码行数:25,代码来源:UserStoreTests.cs

示例8: AccountController

        public AccountController()
        {
            mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);

            KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
            usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
        }
开发者ID:thEpisode,项目名称:Sistema-de-gestion-de-requerimientos-konrad-lorenz,代码行数:7,代码来源:AccountController.cs

示例9: WorkitemsController

        public WorkitemsController()
        {

            _client = new MongoClient("mongodb://localhost:27017");
            _database = _client.GetDatabase("integrity");
            _collection = _database.GetCollection<BsonDocument>("workitems");
        }
开发者ID:DaveWelling,项目名称:IntegrityKatana,代码行数:7,代码来源:WorkitemsController.cs

示例10: CategoryController

 /// <summary>
 /// CategoryController constructor
 /// </summary>
 public CategoryController()
 {
     var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString);
     _log = new Logger("WebAPI:CategoryController");
     _db = client.GetDatabase("patientcaredb");
     _categories = _db.GetCollection<BsonDocument>("Category");
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:10,代码来源:CategoryController.cs

示例11: HomeController

 public HomeController()
 {
     connectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
     mongoClient = new MongoClient(connectionString);
     db = mongoClient.GetDatabase("zngndb");
     userCollection = db.GetCollection<BsonDocument>("User");
 }
开发者ID:huseyinzengin91,项目名称:MongoDBCRUD,代码行数:7,代码来源:HomeController.cs

示例12: MessageDeduplicationPersistorMongoDb

 public MessageDeduplicationPersistorMongoDb()
 {
     var settings = DeduplicationFilterSettings.Instance;
     var mongoClient = new MongoClient(settings.ConnectionStringMongoDb);
     var mongoDatabase = mongoClient.GetDatabase(settings.DatabaseNameMongoDb);
     _collection = mongoDatabase.GetCollection<ProcessedMessage>(settings.CollectionNameMongoDb);
 }
开发者ID:R-Suite,项目名称:ServiceConnect-CSharp,代码行数:7,代码来源:MessageDeduplicationPersistorMongoDb.cs

示例13: MongoService

 public MongoService()
 {
     var mongo = new Mongo();
     mongo.Connect();
     IMongoDatabase mongoDatabase = mongo.GetDatabase(ConfigurationManager.AppSettings["Database"]);
     _collection = mongoDatabase.GetCollection<Entity>("entity");
 }
开发者ID:christiaan-stoffer,项目名称:euh,代码行数:7,代码来源:MongoService.cs

示例14: UpdateModifiersTests

 public UpdateModifiersTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
     _collection = _server.GetCollection<Post>("Posts");
     _buildInfo = admin.BuildInfo();
 }
开发者ID:gaoninggn,项目名称:NoRM,代码行数:7,代码来源:UpdateModifiersTests.cs

示例15: Logger

 public Logger(string logger)
 {
     var client = new MongoClient(Properties.Settings.Default.Mongo_log);
     _db = client.GetDatabase("patientcarelog");
     _logCollection = _db.GetCollection<BsonDocument>("Logs");
     _logger = logger;
 }
开发者ID:dsb92,项目名称:patientcare,代码行数:7,代码来源:Logger.cs


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