本文整理汇总了C#中IMongoDatabase类的典型用法代码示例。如果您正苦于以下问题:C# IMongoDatabase类的具体用法?C# IMongoDatabase怎么用?C# IMongoDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMongoDatabase类属于命名空间,在下文中一共展示了IMongoDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectionExpression
public CollectionExpression(Alias alias, IMongoDatabase database, string collectionName, Type documentType)
: base(MongoExpressionType.Collection, typeof(void), alias)
{
CollectionName = collectionName;
Database = database;
DocumentType = documentType;
}
示例2: GetAllProducts
public ICollection<Product> GetAllProducts(IMongoDatabase database, string collectionName)
{
var collection = database.GetCollection<Product>(collectionName);
var rest = collection.Find(_ => true).ToListAsync().Result;
return rest;
}
示例3: firstTimeInstallDataBase
private async void firstTimeInstallDataBase (IMongoDatabase database, string rootPath){
try {
if (!CollectionExistsAsync (database, "actors").Result) {
await database.CreateCollectionAsync ("actors");
var actors = new ActorRepository();
foreach (Actor actor in actors.Retrieve(rootPath))
{
var collectionActors = database.GetCollection<Actor>("actors");
await collectionActors.InsertOneAsync(actor);
}
}
if (!CollectionExistsAsync (database, "movies").Result) {
await database.CreateCollectionAsync ("movies");
var movies = new MovieRepository();
foreach (Movie movie in movies.Retrieve(rootPath))
{
var collectionActors = database.GetCollection<Movie>("movies");
await collectionActors.InsertOneAsync(movie);
}
}
}
catch {
throw;
}
}
示例4: MongoDBStorage
public MongoDBStorage(IMongoDatabase database)
{
Revisions = database.GetCollection<RevisionModel>("revisions");
Users = database.GetCollection<UserModel>("users");
Task.Run(() => SetUp()).Wait();
}
示例5: GetCollection
public IMongoCollection<BsonDocument> GetCollection(IMongoDatabase mongoDatabase, bool? cappedCollection,
string collectionName, long? cappedCollectionSize, long? maxNumberOfDocuments)
{
IMongoCollection<BsonDocument> retVal = null;
if (cappedCollection == null || !cappedCollection.Value)
{
retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
return retVal;
}
if (!IsCollectionExistsAsync(mongoDatabase, collectionName).Result)
{
CreateCollectionAsync(mongoDatabase, collectionName, cappedCollectionSize, maxNumberOfDocuments).Wait();
retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
return retVal;
}
if (IsCappedCollection(collectionName, mongoDatabase).Result)
{
retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
return retVal;
}
if (ConvertCollectionToCapped(collectionName, mongoDatabase, cappedCollectionSize, maxNumberOfDocuments).Result)
{
retVal = mongoDatabase.GetCollection<BsonDocument>(collectionName ?? CollectionDefaulName);
}
return retVal;
}
示例6: TokenHandleStore
public TokenHandleStore(IMongoDatabase db,
StoreSettings settings,
IClientStore clientStore)
: base(db, settings.TokenHandleCollection)
{
_serializer = new TokenSerializer(clientStore);
}
示例7: AdminService
public AdminService(IMongoClient client, IMongoDatabase db, StoreSettings settings)
{
_client = client;
_db = db;
_settings = settings;
_clientSerializer = new ClientSerializer();
}
示例8: MongoConfigurationRepository
public MongoConfigurationRepository(string connection, string databaseName)
{
var mongoClient = new MongoClient(MongoClientSettings.FromUrl(new MongoUrl(connection ?? Connection)));
database = mongoClient.GetDatabase(databaseName ?? DatabaseName);
InitCollection();
}
示例9: Init
public void Init()
{
Client = new MongoClient(ConnString);
DataBase = Client.GetDatabase("mongoLog");
Users = DataBase.GetCollection<User>("Users");
Datas = DataBase.GetCollection<Data>("Datas");
}
示例10: MProjects
static MProjects()
{
var connectionString = Settings.Default.MongoConnectionString;
var mongoClient = new MongoClient(connectionString);
Database = mongoClient.GetDatabase(Settings.Default.MongoDBName);
}
示例11: Querying
public Querying()
{
client = new MongoClient(); ;
database = client.GetDatabase("test");
collection = database.GetCollection<Student>("Users");
}
示例12: 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;
}
示例13: DetailController
/// <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");
}
示例14: InitiateDatabase
private void InitiateDatabase()
{
var connectionString = ConfigurationManager.ConnectionStrings["Mongo.ConnectionString"].ConnectionString;
var mongoUrlBuilder = new MongoUrlBuilder(connectionString);
mongoClient = new MongoClient(mongoUrlBuilder.ToMongoUrl());
Database = mongoClient.GetDatabase(mongoUrlBuilder.DatabaseName);
}
示例15: PatientRepository
/// <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");
}