本文整理汇总了C#中IMongoDatabase.GetCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IMongoDatabase.GetCollection方法的具体用法?C# IMongoDatabase.GetCollection怎么用?C# IMongoDatabase.GetCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMongoDatabase
的用法示例。
在下文中一共展示了IMongoDatabase.GetCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init()
{
Client = new MongoClient(ConnString);
DataBase = Client.GetDatabase("mongoLog");
Users = DataBase.GetCollection<User>("Users");
Datas = DataBase.GetCollection<Data>("Datas");
}
示例2: 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;
}
示例3: MongoDBStorage
public MongoDBStorage(IMongoDatabase database)
{
Revisions = database.GetCollection<RevisionModel>("revisions");
Users = database.GetCollection<UserModel>("users");
Task.Run(() => SetUp()).Wait();
}
示例4: GetNextHi
private long GetNextHi(string collectionName, IMongoDatabase database)
{
while (true)
{
try
{
var update = new Expando();
update["$inc"] = new { ServerHi = 1 };
var hiLoKey = database.GetCollection<NormHiLoKey>().FindAndModify(new { _id = collectionName }, update);
if (hiLoKey == null)
{
database.GetCollection<NormHiLoKey>().Insert(new NormHiLoKey { CollectionName = collectionName, ServerHi = 2 });
return 1;
}
var newHi = hiLoKey.ServerHi;
return newHi;
}
catch (MongoException ex)
{
if (!ex.Message.Contains("duplicate key"))
throw;
}
}
}
示例5: AgentController
public AgentController()
{
mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);
KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
requirementsCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Requirements");
}
开发者ID:thEpisode,项目名称:Sistema-de-gestion-de-requerimientos-konrad-lorenz,代码行数:8,代码来源:AgentController.cs
示例6: MongoModelRepository
public MongoModelRepository(IMongoDatabase database)
{
_composedModelsCollection = database.GetCollection<ComposedModel>("ComposedModel");
_setDataCollection = database.GetCollection<SetData>("SetData");
_parameterDataCollection = database.GetCollection<ParameterDataStorageModel>("ParameterData");
_parameterDataItemCollection = database.GetCollection<ParameterDataItemStorageModel>("ParameterDataItem");
_scenariosCollection = database.GetCollection<Scenario>("Scenario");
}
示例7: DealsDb
public DealsDb(string databaseName)
{
var cli = new MongoClient("mongodb://localhost:27017");
db = cli.GetDatabase(databaseName);
dealCollection = db.GetCollection<Deal>(DealsCollectionName);
userCollection = db.GetCollection<User>(UserCollectionName);
ratingCollection = db.GetCollection<Rating>(RatingCollectionName);
LoggedInUsers = new Dictionary<Guid, User>();
}
示例8: MongoService
// useful resources:
// http://mongodb.github.io/mongo-csharp-driver/2.0/getting_started/quick_tour/
// http://dotnetcodr.com/data-storage/
/// <summary>
/// Default constructor for the repository
/// </summary>
public MongoService()
{
string connection = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
client = new MongoClient(connection);
database = client.GetDatabase("CMEdata");
inputdata = database.GetCollection<InputData>("inputdata");
datesets = database.GetCollection<DateSet>("datesets");
tests = database.GetCollection<Test>("tests");
}
示例9: HomeController
public HomeController()
{
mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString);
KonradRequirementsDatabase = mongoClient.GetDatabase("KonradRequirements");
usersCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Users");
requirementsCollection = KonradRequirementsDatabase.GetCollection<BsonDocument>("Requirements");
//https://www.mongodb.com/blog/post/introducing-20-net-driver?jmp=docs&_ga=1.196294954.721581952.1441258055
}
开发者ID:thEpisode,项目名称:Sistema-de-gestion-de-requerimientos-konrad-lorenz,代码行数:10,代码来源:HomeController.cs
示例10: MongoDbRepository
public MongoDbRepository(IOptions<AppSettings> appSettings)
{
_client = new MongoClient(appSettings.Value.MongoDbConnectionString);
_database = _client.GetDatabase(appSettings.Value.MongoDbName);
_tweetCollection = _database.GetCollection<Tweet>("tweets");
_userFollowsCollection = _database.GetCollection<UserFollows>("user_follows");
_userLikesCollection = _database.GetCollection<UserLikes>("user_likes");
_conversationCollection = _database.GetCollection<Conversation>("conversations");
_userNotificationCollection = _database.GetCollection<UserNotifications>("user_notifications");
}
示例11: ImportNewUsersStep
public ImportNewUsersStep(string database, string repository, string month)
{
_repository = repository;
_month = month;
var client = new MongoClient("mongodb://app-svr.cloudapp.net:27017/" + database);
_database = client.GetDatabase(database);
_userCollection = _database.GetCollection<BsonDocument>("users");
_threadCollection = _database.GetCollection<BsonDocument>(_repository + "_" + _month + "_" + "threads");
}
示例12: UpdateMonthlyAskerTagsToAskerActivityStep
public UpdateMonthlyAskerTagsToAskerActivityStep(string database, string repository, string month)
{
_repository = repository;
_month = month;
var client = new MongoClient("mongodb://app-svr.cloudapp.net:27017/" + database);
_database = client.GetDatabase(database);
_askerTagCollection = _database.GetCollection<BsonDocument>(_repository + "_user_tags");
_askerActivityCollection = _database.GetCollection<BsonDocument>(_repository + "_asker_activities");
}
示例13: ImportNewUsersStep
public ImportNewUsersStep(string repository, string month, EasyAnalysis.Framework.ConnectionStringProviders.IConnectionStringProvider mongoDBDataProvider)
{
_repository = repository;
_month = month;
var client = new MongoClient(mongoDBDataProvider.GetConnectionString(repository));
_database = client.GetDatabase(repository);
_userCollection = _database.GetCollection<BsonDocument>("users");
_threadCollection = _database.GetCollection<BsonDocument>(_month + "_" + "threads");
}
示例14: GetAllTraders
public ICollection<Trader> GetAllTraders(IMongoDatabase database)
{
var collection = database.GetCollection<Trader>(TradersCollectionName);
var rest = collection.Find(t => true).ToListAsync().Result;
return rest;
}
示例15: Querying
public Querying()
{
client = new MongoClient(); ;
database = client.GetDatabase("test");
collection = database.GetCollection<Student>("Users");
}