本文整理汇总了C#中Session.GetCollection方法的典型用法代码示例。如果您正苦于以下问题:C# Session.GetCollection方法的具体用法?C# Session.GetCollection怎么用?C# Session.GetCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session.GetCollection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExistsWithOriginalSourceId
public override bool ExistsWithOriginalSourceId(string link)
{
using (var session = new Session())
{
var collection = session.GetCollection<OpportunityDocument>();
var exists = collection.Count(d => d.OriginalSourceName == SourceName && d.OriginalSourceId == link) > 0;
return exists;
}
}
示例2: FindByOriginalSourceId
public override Opportunity FindByOriginalSourceId(string link)
{
using (var session = new Session())
{
var collection = session.GetCollection<OpportunityDocument>();
var document = collection.FindOne(d => d.OriginalSourceName == SourceName && d.OriginalSourceId == link);
return mapper.Map<Opportunity>(document);
}
}
示例3: Save
public override void Save(Opportunity item)
{
var documetn = mapper.Map<OpportunityDocument>(item);
using (var session = new Session())
{
var collection = session.GetCollection<OpportunityDocument>();
collection.Insert(documetn);
collection.EnsureIndex(d => d.Title);
}
}
示例4: Update
public override void Update(Opportunity opportunity)
{
using (var session = new Session())
{
var collection = session.GetCollection<OpportunityDocument>();
var document = collection.FindOne(d => d.Id == opportunity.Id);
mapper.Map(opportunity, document);
collection.Update(document);
}
}
示例5: FindAll
public override IEnumerable<Opportunity> FindAll()
{
var result = new Collection<Opportunity>();
using (var session = new Session())
{
var collection = session.GetCollection<OpportunityDocument>();
foreach (var document in collection.FindAll())
{
result.Add(mapper.Map<Opportunity>(document));
}
}
return result;
}