本文整理汇总了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;
}
示例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);
}
示例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();
}
示例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();
}
示例5: Querying
public Querying()
{
client = new MongoClient(); ;
database = client.GetDatabase("test");
collection = database.GetCollection<Student>("Users");
}
示例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");
}
示例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);
}
示例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");
}
示例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");
}
示例11: HomeController
public HomeController()
{
connectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
mongoClient = new MongoClient(connectionString);
db = mongoClient.GetDatabase("zngndb");
userCollection = db.GetCollection<BsonDocument>("User");
}
示例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);
}
示例13: MongoService
public MongoService()
{
var mongo = new Mongo();
mongo.Connect();
IMongoDatabase mongoDatabase = mongo.GetDatabase(ConfigurationManager.AppSettings["Database"]);
_collection = mongoDatabase.GetCollection<Entity>("entity");
}
示例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();
}
示例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;
}