本文整理汇总了C#中MongoRepository.Select方法的典型用法代码示例。如果您正苦于以下问题:C# MongoRepository.Select方法的具体用法?C# MongoRepository.Select怎么用?C# MongoRepository.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoRepository
的用法示例。
在下文中一共展示了MongoRepository.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPangramsLimit
public GetPangramResponse GetPangramsLimit(int limit)
{
IRepository<Pangram> _pangramRepo = new MongoRepository<Pangram>();
GetPangramResponse getPangramResponse = new GetPangramResponse();
if (limit > 0)
{
var pangrams = _pangramRepo.Select(p => p)
.Take(limit)
.ToList();
if (pangrams.Count() > 0)
{
foreach (var pa in pangrams)
{
getPangramResponse.pangrams.Add(pa.Sentence);
}
}
}
return new GetPangramResponse()
{
Content = new JsonContent2(
getPangramResponse
)
};
}
示例2: Index
public ActionResult Index()
{
var model = new DeploymentJointModel();
var Companies = new MongoRepository<Company>();
model.ModelForView.Company = Companies.Select(c => new SelectListItem
{
Value = c.CompanyKey,
Text = c.CompanyName
});
var Environments = new MongoRepository<Entities.Environment>();
model.ModelForView.Environment = Environments.Select(e => new SelectListItem
{
Value = e.Id,
Text = e.Name
});
var Revisions = new MongoRepository<Revision>();
model.ModelForView.Revision = Revisions.Select(r => new SelectListItem
{
Value = r.Id,
Text = r.Tag
});
return View(model);
}
示例3: PostPangram
public HttpResponseMessage PostPangram([FromBody]string sentence)
{
CreatePangramResponse createPangramResponse = new CreatePangramResponse();
createPangramResponse.isPangram = false;
IRepository<Pangram> _pangramRepo = new MongoRepository<Pangram>();
if (!String.IsNullOrEmpty(sentence))
{
var pangram = new Pangram(sentence);
if (pangram.isPangram)
{
var pangrams = _pangramRepo.Select(p => p).ToList();
var checkForSamePangramInRepo = pangrams.AsEnumerable().Where(p => p.Sentence == sentence).Select(p => p.Sentence).ToList();
if (checkForSamePangramInRepo.Count() == 0)
{
_pangramRepo.Add(pangram);
}
createPangramResponse.isPangram = true;
}
}
return new HttpResponseMessage()
{
Content = new JsonContent2(
createPangramResponse
)
};
}