private ApplicationIdentityContext(IMongoCollection<ApplicationUser> users, IMongoCollection<IdentityRole> roles, IMongoCollection<Client> clients, IMongoCollection<RefreshToken> refreshTokens) { Users = users; Roles = roles; Clients = clients; RefreshTokens = refreshTokens; }
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"); }
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); }
public AccountController() { mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString); KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements"); usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users"); }
public WorkitemsController() { _client = new MongoClient("mongodb://localhost:27017"); _database = _client.GetDatabase("integrity"); _collection = _database.GetCollection<BsonDocument>("workitems"); }
/// <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"); }
public HomeController() { connectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString; mongoClient = new MongoClient(connectionString); db = mongoClient.GetDatabase("zngndb"); userCollection = db.GetCollection<BsonDocument>("User"); }
public MessageDeduplicationPersistorMongoDb() { var settings = DeduplicationFilterSettings.Instance; var mongoClient = new MongoClient(settings.ConnectionStringMongoDb); var mongoDatabase = mongoClient.GetDatabase(settings.DatabaseNameMongoDb); _collection = mongoDatabase.GetCollection<ProcessedMessage>(settings.CollectionNameMongoDb); }
public Querying() { client = new MongoClient(); ; database = client.GetDatabase("test"); collection = database.GetCollection<Student>("Users"); }
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); }
public Logger(string logger) { var client = new MongoClient(Properties.Settings.Default.Mongo_log); _db = client.GetDatabase("patientcarelog"); _logCollection = _db.GetCollection<BsonDocument>("Logs"); _logger = logger; }
private static void AddMovies(IMongoCollection<Movie> collection) { var movies = new List<Movie> { new Movie { Title = "The Perfect Developer", Category = "SciFi", Minutes = 118 }, new Movie { Title = "Lost In Frankfurt am Main", Category = "Horror", Minutes = 122 }, new Movie { Title = "The Infinite Standup", Category = "Horror", Minutes = 341 } }; //collection.InsertBatch(movies); collection.InsertManyAsync(movies).Wait(); }
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(); }
public void Initialize() { var connect = "mongodb://localhost"; _client = new MongoClient(connect); _db = _client.GetDatabase("local"); _collection = _db.GetCollection<Person>("Person"); }
public LogEntryRepository(MongoClient mongoClient, IConfiguration configuration, string databaseName = "Kelpie") { _mongoClient = mongoClient; _configuration = configuration; _database = _mongoClient.GetDatabase(databaseName); _collection = _database.GetCollection<LogEntry>("LogEntry"); }
public MongoService() { var mongo = new Mongo(); mongo.Connect(); IMongoDatabase mongoDatabase = mongo.GetDatabase(ConfigurationManager.AppSettings["Database"]); _collection = mongoDatabase.GetCollection<Entity>("entity"); }
public PreviousMonthsController() { var client = new MongoClient(); var database = client.GetDatabase("Operativ"); сollectionBisc = database.GetCollection<Month>("BISC"); collectionIsc = database.GetCollection<Month>("ISC"); }
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(); }
public void loadColors(IMongoCollection<board_item> coll, string boardName) { List<board_item> colors = coll.Find(brd => brd.Type == "Color" && brd.Board_Name == boardName) .ToListAsync() .Result; int i = 1; foreach (board_item color in colors) { if (i == 1) { colorPlace1.ImageUrl = color.Image_Link; i++; colorPlace2.ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Solid_white.svg/2000px-Solid_white.svg.png"; } else if (i == 2) { colorPlace2.ImageUrl = color.Image_Link; i++; colorPlace3.ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Solid_white.svg/2000px-Solid_white.svg.png"; } else if (i == 3) { colorPlace3.ImageUrl = color.Image_Link; } } }
public TodoItemRepository(string mongoConnection, string databaseName) { collectionName = "todoitems"; var client = new MongoClient(mongoConnection); this.database = client.GetDatabase(databaseName); this.collection = database.GetCollection<TodoItem>(collectionName); }
/// <summary> /// Details controller constructor /// </summary> public DetailController() { var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare"].ConnectionString); _log = new Logger("WebAPI:DetailController"); _db = client.GetDatabase("patientcaredb"); _details = _db.GetCollection<BsonDocument>("Detail"); }
/// <summary /> public PatientRepository() { var client = new MongoClient(ConfigurationManager.ConnectionStrings["Mongo_patientcare_datamock"].ConnectionString); _log = new Logger("WebAPI : PatientRepository"); _db = client.GetDatabase("patientcare_datamock"); _patients = _db.GetCollection<BsonDocument>("Patients"); }
public SCORMObjectModel(String connectionString) { _ConnectionString = connectionString; _Connection = Mongo.Create(connectionString); _DB = _Connection.GetCollection<SCORMObject>(); _FileStore = Norm.GridFS.Helpers.Files<SCORMObject>(_DB); }
public void Init() { Client = new MongoClient(ConnString); DataBase = Client.GetDatabase("mongoLog"); Users = DataBase.GetCollection<User>("Users"); Datas = DataBase.GetCollection<Data>("Datas"); }
public MongoDBStorage(IMongoDatabase database) { Revisions = database.GetCollection<RevisionModel>("revisions"); Users = database.GetCollection<UserModel>("users"); Task.Run(() => SetUp()).Wait(); }
public static List <T> GetAllSync <T>(this IMongoCollection <T> collection, Expression <Func <T, bool> > expression) { var findFluent = collection.Find <T>(expression); return(findFluent.ToList()); }
public static async Task <List <T> > GetAll <T>(this IMongoCollection <T> collection, Expression <Func <T, bool> > expression) { var findFluent = await collection.FindAsync <T>(expression); return(await findFluent.ToListAsync()); }
public static T GetOneSync <T>(this IMongoCollection <T> collection, Expression <Func <T, bool> > expression) { return(collection.Find <T>(expression).FirstOrDefault()); }
public static async Task <T> GetOne <T>(this IMongoCollection <T> collection, Expression <Func <T, bool> > expression) { return(await(await collection.FindAsync <T>(expression)).FirstOrDefaultAsync()); }
public static async Task <T> GetById <T>(this IMongoCollection <T> collection, ObjectId id) where T : IMongoModel { return(await(await collection.FindAsync <T>(a => a.Id == id)).FirstOrDefaultAsync()); }
protected override async Task SetupCollectionAsync(IMongoCollection <MongoAppEntity> collection) { await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.UserIds)); await collection.Indexes.CreateOneAsync(Index.Ascending(x => x.Name)); }
/// <inheritdoc /> public TaskListRepository( IMongoCollection <TaskList> collection ) { _collection = collection; }
public MongoDbProductRepository(IMongoCollection <Product> collection) { _collection = collection; }
public UserStore(IMongoCollection <TUser> userCollection, IMongoCollection <TRole> roleCollection, ILookupNormalizer normalizer) { _userCollection = userCollection; _roleCollection = roleCollection; _normalizer = normalizer; }
private void GetCollection() { MongoClient client = new MongoClient(); reportCollection = client.GetDatabase(settings.Database).GetCollection <Report>(settings.ReportCollectionName); }
protected MongoRepository(IMongoContext context) { Database = context.Database; DbSet = Database.GetCollection <TEntity>(typeof(TEntity).Name); }
public static async Task <List <T> > GetAll <T>(this IMongoCollection <T> collection) { return(await(await collection.FindAsync <T>(a => true)).ToListAsync()); }
public CartRepository(IMongoDatabase db) { _collection = db.GetCollection <Cart>(Cart.DocumentName); }
public static async Task <long> Count <T>(this IMongoCollection <T> collection, Expression <Func <T, bool> > expression) { return(await collection.CountAsync <T>(expression)); }
private static async Task InsertAsync <T>(IMongoCollection <T> mongoCollection, T record, CancellationToken cancellationToken) { await mongoCollection.InsertOneAsync(record, cancellationToken : cancellationToken); }
public MongoRepository(IMongoClient client) { var database = client.GetDatabase(Constants.MongoDbDatabaseName); _collection = database.GetCollection <T>(typeof(T).Name); }
private static async Task UpdateAsync <T>(IMongoCollection <T> collection, T record, Expression <Func <T, bool> > filter, CancellationToken cancellationToken) { await collection.ReplaceOneAsync <T>(filter, record, new ReplaceOptions { IsUpsert = true }, cancellationToken).ConfigureAwait(false); }
public static string AddKeyPhraseReverseWords(DataConfig providerConfig, List <POCO.RecordAssociationKeyPhraseReverseWord> keyPhrases) { string tableName = ""; switch (providerConfig.ProviderType) { case "azure.tableservice": tableName = Record.AzureTableNames.RecordAssociationKeyPhraseReverseWords; CloudTable table = Utils.GetCloudTable(providerConfig, tableName); keyPhrases.ParallelForEachAsync( async kp => { AzureRecordAssociationKeyPhraseReverseWord az = new AzureRecordAssociationKeyPhraseReverseWord(kp); TableOperation operation = TableOperation.InsertOrReplace(az); TableResult update = await table.ExecuteAsync(operation); }, 6); //foreach (POCO.RecordAssociationKeyPhraseReverseWord kp in keyPhrases) //{ // AzureRecordAssociationKeyPhraseReverseWord az = new AzureRecordAssociationKeyPhraseReverseWord(kp); // TableOperation operation = TableOperation.InsertOrReplace(az); // Task tUpdate = table.ExecuteAsync(operation); // tUpdate.Wait(); //} break; case "internal.mongodb": tableName = Record.MongoTableNames.RecordAssociationKeyPhraseReverseWords; IMongoCollection <MongoRecordAssociationKeyPhraseReverseWord> collection = Utils.GetMongoCollection <MongoRecordAssociationKeyPhraseReverseWord>(providerConfig, tableName); var operationList = new List <WriteModel <MongoRecordAssociationKeyPhraseReverseWord> >(); foreach (POCO.RecordAssociationKeyPhraseReverseWord kp in keyPhrases) { // Convert to mongo-compatible object MongoRecordAssociationKeyPhraseReverseWord mongoObject = Utils.ConvertType <MongoRecordAssociationKeyPhraseReverseWord>(kp); // Create the filter for the upsert FilterDefinition <MongoRecordAssociationKeyPhraseReverseWord> filter = Builders <MongoRecordAssociationKeyPhraseReverseWord> .Filter.Eq(x => x.PartitionKey, kp.PartitionKey) & Builders <MongoRecordAssociationKeyPhraseReverseWord> .Filter.Eq(x => x.RowKey, kp.RowKey); UpdateDefinition <MongoRecordAssociationKeyPhraseReverseWord> updateDefinition = new UpdateDefinitionBuilder <MongoRecordAssociationKeyPhraseReverseWord>().Unset("______"); // HACK: I found no other way to create an empty update definition updateDefinition = updateDefinition .SetOnInsert("PartitionKey", mongoObject.PartitionKey) .SetOnInsert("RowKey", mongoObject.RowKey) .Set("WordNumber", mongoObject.WordNumber) .Set("TotalWords", mongoObject.TotalWords); UpdateOneModel <MongoRecordAssociationKeyPhraseReverseWord> update = new UpdateOneModel <MongoRecordAssociationKeyPhraseReverseWord>(filter, updateDefinition) { IsUpsert = true }; operationList.Add(update); } if (operationList.Count > 0) { collection.BulkWrite(operationList); } return(string.Empty); default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } //TODO return id of new object if supported return(string.Empty); }
public MongoQueryRepository(IMongoContext context) { _collection = context.Database.GetCollection <T>(typeof(T).Name); _queryable = _collection.AsQueryable(); }
public void SetCollection(string collectionName) { _collection = _mongoDBContext.DataBase.GetCollection <TEntity>(collectionName); }
public DbRepository(IDbContext dbContext) { _dbContext = dbContext; _collection = _dbContext.GetCollection <T>(typeof(T).Name); }
public MongoDbSource(IMongoCollection <AppSetting> collection) { _collection = collection; }
public EventStore(DatabaseContext databaseContext) { _databaseContext = databaseContext; _mongoCollection = databaseContext.GetCollectionFor <PersistedEvent>(); }
public AuthController(IDatabaseSettings databaseSettings, IUserService userService) { UserService = userService; Users = databaseSettings.GetCollection <User>(); }
public GetInvoicesQuery(DbContext context) { _collection = context.GetInvoicesCollection(); }
public MongoRepository(IMongoDatabase database) { Collection = database.GetCollection <TEntity>(typeof(TEntity).Name); }
public static async Task <T> GetById <T>(this IMongoCollection <T> collection, string id) where T : IMongoModel { var objectId = new ObjectId(id); return(await(await collection.FindAsync <T>(a => a.Id == objectId)).FirstOrDefaultAsync()); }
public IdentityUserCollection(string connectionString, string collectionName) { _users = MongoUtil.FromConnectionString <TUser>(connectionString, collectionName); }
public static Task UpsertUserAsync(this IMongoCollection <User> collection, ulong userId, ulong guildId, Action <User> update) => collection.UpsertAsync(x => x.UserId == userId && x.GuildId == guildId, update, GetFactory(userId, guildId));
public ProjectFeedRepository() { Database = DatabaseProvider.GetDatabase(); _collection = CollectionProvider.GetCollection <ProjectFeed>(Database); }
static async Task findDocuments(IMongoCollection<student> collection, FilterDefinition<student> searchFilter) { //Option 1: for iterting over many documents on the server. Console.WriteLine("--------------------------------------------------------------------"); using (var cursor = await collection.Find(searchFilter) .Sort("{student_id:1, score:-1}") .ToCursorAsync()) { int i = 1; using (StreamWriter w = File.AppendText("c:\\data\\test2.txt")) { while (await cursor.MoveNextAsync()) //iterate over each batch { foreach (var doc in cursor.Current) { string text = i + " :=> sid: " + doc.student_id + ":" + doc.score; Console.WriteLine(text); w.WriteLine(text); if (i % 4 == 0) { Console.WriteLine("lowest score for " + doc.student_id + " is " + doc.score); w.WriteLine("lowest score for " + doc.student_id + " is " + doc.score); await collection.DeleteOneAsync(a => a.Id == doc.Id); } i++; } } } } }
protected void SetUp() { var f = new FileStream("config.json", FileMode.Open); var sr = new StreamReader(f); try { var settings = JsonConvert .DeserializeObject<MongoSettings>(sr.ReadToEnd()); var client = new MongoClient(new MongoUrl(settings.Url)); _database = client.GetDatabase(settings.DatabaseName); } catch (FileNotFoundException) { throw new Exception("Talk to John about why this one fails"); } finally { f.Dispose(); sr.Dispose(); } _collectionName = Guid.NewGuid().ToString(); _collection = _database.GetCollection<Container>(_collectionName); var mapper = new StringMapper<BasePaymentModel>(x => x.PaymentType) .Register<AchInputModel>("ach") .Register<CreditCardInputModel>("cc") .Register<PayPalInputModel>("paypal"); BsonSerializer.RegisterDiscriminatorConvention( typeof(BasePaymentModel), new DiscriminatorConvention<string, BasePaymentModel>(mapper)); }
public GameRepository() { string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Mongodb"].ConnectionString; _client = new MongoClient(connection); _database = _client.GetDatabase(System.Configuration.ConfigurationManager.AppSettings["DataBaseName"]); _collection = _database.GetCollection<GameEntity>("games"); }
public void loadColors(IMongoCollection<board_item> coll, string boardName) { List<board_item> colors = coll.Find(brd => brd.Type == "Color" && brd.Board_Name == boardName) .ToListAsync() .Result; int i = 1; foreach (board_item color in colors) { if (i == 1) { colorPlace1.ImageUrl = color.Image_Link; i++; } else if (i == 2) { colorPlace2.ImageUrl = color.Image_Link; i++; } else if (i == 3) { colorPlace3.ImageUrl = color.Image_Link; } } }
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(); }