本文整理汇总了C#中IMongoClient类的典型用法代码示例。如果您正苦于以下问题:C# IMongoClient类的具体用法?C# IMongoClient怎么用?C# IMongoClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMongoClient类属于命名空间,在下文中一共展示了IMongoClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BookContext
public BookContext(IMongoClient mc)
{
//Connecting to local
client = mc;
this.db = client.GetDatabase("bookStore");
}
开发者ID:cesaroll,项目名称:MongoDb_C-Net_BookApp,代码行数:7,代码来源:BookContext.cs
示例2: AdminService
public AdminService(IMongoClient client, IMongoDatabase db, StoreSettings settings)
{
_client = client;
_db = db;
_settings = settings;
_clientSerializer = new ClientSerializer();
}
开发者ID:FeodorFitsner,项目名称:IdentityServer.v3.Admin.MongoDb,代码行数:7,代码来源:AdminService.cs
示例3: GetActiveDatabases
static List<string> GetActiveDatabases(IMongoClient client)
{
List<string> dbs = new List<string>();
using (var cursor = client.ListDatabases()) // await + Async() seem to exit the programm ... @@@ ask Piercesare why
{
cursor.ForEachAsync(d => dbs.Add(d.GetElement("name").Value.AsString)); //use await?
}
return dbs;
}
开发者ID:BertiFuchsi,项目名称:GanovenFutter,代码行数:9,代码来源:Connector.cs
示例4: DistrictsRepository
public DistrictsRepository(IMongoClient client, string database)
{
// todo: move this out to IOC config
var cp = new ConventionPack();
cp.Add(new CamelCaseElementNameConvention());
ConventionRegistry.Register("camel case", cp, x => true);
_client = client;
_db = _client.GetDatabase(database);
_collection = _db.GetCollection<District>("districts");
}
开发者ID:tbehunin,项目名称:kulepool,代码行数:11,代码来源:DistrictsRepository.cs
示例5: Disconnect
public static void Disconnect()
{
if (_mongoClient != null)
{
_mongoClient = null;
}
Databases = null;
}
开发者ID:r0flbear,项目名称:MongoInterface,代码行数:9,代码来源:Connection.cs
示例6: Main
public static void Main(string[] args)
{
// #Connect to Db Shop => caseSensitive!!!
client = new MongoClient("mongodb://127.0.0.1");
database = client.GetDatabase("Shop");
//var eDrink = new EnergyDrink("Hell", 1.05);
// #connect to table EnergyDrinks
var drinksCollection = database.GetCollection<EnergyDrink>("EnergyDrinks");
while (true)
{
Console.Clear();
Console.WriteLine("Enter command:");
Console.WriteLine("Add new drink: => 1");
Console.WriteLine("Get all drinks: => 2");
Console.WriteLine("Get drinks by name => 3");
Console.WriteLine("Get drinks by price => 4");
var command = Console.ReadLine();
switch (command)
{
case "1": InsertToDatabase(drinksCollection); break;
case "2": GetAllDrinks(drinksCollection); break;
case "3": SearchByName(drinksCollection); break;
case "4": SearchByPrice(drinksCollection); break;
default:
break;
}
}
}
开发者ID:ni4ka7a,项目名称:TelerikAcademyHomeworks,代码行数:33,代码来源:EntryPoint.cs
示例7: DatabaseContext
static DatabaseContext()
{
//var connectionString = ConfigurationManager.ConnectionStrings[CONNECTION_STRING_NAME].ConnectionString;
var connectionString = "mongodb://dbadmin:[email protected]:55722/edubase";
_client = new MongoClient(connectionString);
_database = _client.GetDatabase(DATABASE_NAME);
}
开发者ID:wadim1611,项目名称:CourseBuildingsSystemMVCandWCF,代码行数:7,代码来源:DatabaseContext.cs
示例8: InsertMongoDb
public static void InsertMongoDb()
{
try
{
_client = new MongoClient();
_database = _client.GetDatabase("test");
var document = new BsonDocument
{
{
"Utilisateur", new BsonDocument
{
{"id", "1"},
{"nom", "LAMGHARI"},
{"prenom", "Mohammed"},
{"mail", "mail"},
{"pseudo", "dskat747"},
{"mdp", "1234"},
{"handicap", "false"},
{
"ProfileParking", new BsonDocument
{
{"id", "2"},
{"profil", "admin"}
}
},
{"Reservation", new BsonDocument
{
{"id", "15"},
{"Place", new BsonDocument
{
{"id", "1"},
{"profile", "admin"},
{"mac_address", "DF,15,21,DF,00"},
{"nom", "place 01"},
{"Parking", new BsonDocument
{
{"adresse", "Valenciennes"},
{"NbPlace", "150"},
{"etat", "Operationnel"}
}
}
}
}
}
}
}
}
};
var collection = _database.GetCollection<BsonDocument>("test");
//collection.InsertOne(document);
}
catch (Exception)
{
throw;
}
}
开发者ID:dimafoot,项目名称:EBusiness2,代码行数:60,代码来源:Program.cs
示例9: DataStore
private DataStore(string databaseName, MongoDatabaseSettings settings = null)
{
_client = new MongoClient();
_database = _client.GetDatabase(databaseName, settings);
DatabaseName = databaseName;
}
开发者ID:mingezhao,项目名称:PersonalTools,代码行数:7,代码来源:DataStore.cs
示例10: DefaultController
public DefaultController() {
_client = new MongoClient(new MongoClientSettings
{
Server = new MongoServerAddress("localhost", 27017)
});
_database = _client.GetDatabase("test");
}
开发者ID:jmistx,项目名称:MongoAspTemplate,代码行数:7,代码来源:DefaultController.cs
示例11: DocumentDb
public DocumentDb(string DBName,ISchemaContext SchemaContext)
{
_client = new MongoClient();
_database = _client.GetDatabase(DBName);
ctx = SchemaContext;
this.DBName = DBName;
}
开发者ID:anwarminarso,项目名称:IDLake,代码行数:7,代码来源:DocumentDb.cs
示例12: GameRepository
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");
}
开发者ID:sheldonaj,项目名称:blackjackASP,代码行数:7,代码来源:GameRepository.cs
示例13: getMongoDB
public static IMongoDatabase getMongoDB()
{
_client = new MongoClient("mongodb://145.24.222.168/CityGis"); //Connection string gaat hier
//_client = new MongoClient("mongodb://localhost/CityGis");
_database = _client.GetDatabase("CityGis");
return _database;
}
开发者ID:ChuckTenton,项目名称:CityGist-Project-56,代码行数:7,代码来源:DatabaseConnection.cs
示例14: MongoConfig
public MongoConfig()
{
_client = new MongoClient(ConfigurationManager.AppSettings["eTimeSheetsConnectionString"]);
Database = _client.GetDatabase(ConfigurationManager.AppSettings["eTimeSheetsDBName"]);
}
开发者ID:DureSameen,项目名称:eTimeSheets.API,代码行数:8,代码来源:MongoConfig.cs
示例15: MongoRepository
public MongoRepository()
{
var connectionstring = "mongodb://localhost:27017";
_client = new MongoClient(connectionstring);
_database = _client.GetDatabase("test");
_collection = _database.GetCollection<BsonDocument>("restaurants");
}
开发者ID:d-pepper,项目名称:MongoDataSource.API,代码行数:8,代码来源:MongoRepository.cs
示例16: MongoDBManager
public MongoDBManager()
{
_mongoClient = new MongoClient(ConfigurationManager.ConnectionStrings["DrustveneMrezeConnectionString"].ConnectionString);
_mongoUserInfoDatabase = _mongoClient.GetDatabase(ConfigurationManager.AppSettings["DrustveneMrezeDatabaseName"]);
_mongoMoviesDatabase = _mongoClient.GetDatabase(ConfigurationManager.AppSettings["DrustveneMrezeMoviesDatabaseName"]);
_mongoTweetsDatabase = _mongoClient.GetDatabase(ConfigurationManager.AppSettings["DrustveneMrezeTweetsDatabaseName"]);
}
开发者ID:Kaca992,项目名称:DrustveneMreze,代码行数:8,代码来源:MongoDBManager.cs
示例17: MongoConnection
public static IMongoDatabase MongoConnection() {
client = new MongoClient("mongodb://145.24.222.117/Planetis3");
database = client.GetDatabase("Planetis3");
return database;
}
开发者ID:SnipSnapper,项目名称:WebApplication,代码行数:8,代码来源:DBConnection.cs
示例18: DB
protected DB(string connectionString)
{
var url = MongoUrl.Create(connectionString);
_client = new MongoClient(url);
_database = _client.GetDatabase(url.DatabaseName);
}
开发者ID:Lokimora,项目名称:TimeManager,代码行数:8,代码来源:DB.cs
示例19: OneTimeSetup
private static bool OneTimeSetup()
{
var connectionString = CoreTestConfiguration.ConnectionString.ToString();
__client = new MongoClient(connectionString);
__database = __client.GetDatabase("test");
LoadDataSetFromResource();
return true;
}
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:8,代码来源:PrimerTestFixture.cs
示例20: MdbContext
public MdbContext()
{
_client = new MongoClient();
_database = _client.GetDatabase("Recab");
Forms = _database.GetCollection<BsonDocument>("Forms");
Users = _database.GetCollection<BsonDocument>("Users");
Categoris = _database.GetCollection<BsonDocument>("Categoris");
Prodocts = _database.GetCollection<BsonDocument>("Prodocts");
}
开发者ID:miri-rasoul,项目名称:Recab,代码行数:9,代码来源:MdbContext.cs
注:本文中的IMongoClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论