本文整理汇总了C#中IMongoCollection.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# IMongoCollection.AsQueryable方法的具体用法?C# IMongoCollection.AsQueryable怎么用?C# IMongoCollection.AsQueryable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMongoCollection
的用法示例。
在下文中一共展示了IMongoCollection.AsQueryable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryFromCollection
/// <summary>
/// Demo querying the collection with Linq.
/// </summary>
/// <param name="orders">The orders.</param>
private static void QueryFromCollection(IMongoCollection orders)
{
Console.WriteLine("\n\n======= Query Using Linq =======");
// Query the orders collection.
IQueryable<Document> results =
from doc in orders.AsQueryable()
where doc.Key("customerName") == "Elmer Fudd"
select doc;
Document result = results.FirstOrDefault();
Console.WriteLine(string.Format("Found: {0}", result));
}
示例2: ProjectReiAnswer
public static void ProjectReiAnswer(IMongoCollection<REI> coll, ReportingEntityInstance rei)
{
var entity = new REI(rei.ReportingEntityId, rei.FormDefinitionId,
rei.ControlAnswers.Select(a => new Answer(a.Value.ControlId, a.Value.Values)));
if(coll.AsQueryable().Any(r => r.Id == rei.ReportingEntityId))
{
//update
coll.ReplaceOne(r => r.Id == entity.Id, entity);
}
else
{
coll.InsertOne(entity);
}
}
示例3: Linq
private static Task Linq(IMongoCollection<Person> col)
{
col.AsQueryable().Where(x => x.Id == "my id" && x.Name == "Jack").GetExecutionModel();
return Task.FromResult(true);
}