本文整理汇总了C#中DataStore.GetCollection方法的典型用法代码示例。如果您正苦于以下问题:C# DataStore.GetCollection方法的具体用法?C# DataStore.GetCollection怎么用?C# DataStore.GetCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStore
的用法示例。
在下文中一共展示了DataStore.GetCollection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHistory
public List<HistoryModel> GetHistory(string symbol, DateTime? startDate, DateTime? endDate)
{
using (var db = new DataStore<HistoryModel>("history"))
{
if (startDate == null || endDate == null)
{
startDate = DateTime.Now.AddYears(-3);
endDate = DateTime.Now;
}
var history = db.GetCollection().Where(x => x.Symbol == symbol && x.Date >= startDate.Value && x.Date <= endDate.Value);
if (!history.Any())
{
var json = _yqlService.FetchHistory(symbol, startDate.Value, endDate.Value);
var jobj = JObject.Parse(json);
if (Convert.ToInt32(((JValue)(jobj["query"]["count"])).Value) > 0)
{
history = Helper.DeserializeJson<List<HistoryModel>>(JArray.Parse(jobj["query"]["results"]["quote"].ToString()));
history.ToList().ForEach(x => x.Symbol = symbol);
SaveHistory(history.ToList());
}
}
return history.ToList();
}
}
示例2: GetCachedSectors
public List<SectorModel> GetCachedSectors()
{
using (var db = new DataStore<SectorModel>("sectors"))
{
return db.GetCollection();
}
}
示例3: GetSector
public List<SectorModel> GetSector(int sectorId)
{
List<SectorModel> lst = null;
using (var db = new DataStore<SectorModel>("subsectors"))
{
lst = db.GetCollection().Where(x => x.ParentSectorId == sectorId).ToList();
}
if (lst != null && !lst.Any())
{
lst = GetSubSectors(sectorId);
SaveSubSectors(lst);
}
return lst;
}
示例4: GetCompanies
public IndustryModel GetCompanies(int industryId)
{
using (var db = new DataStore<IndustryModel>("industry"))
{
var industry = db.GetCollection().Find(x => x.Id == industryId);
if (industry == null)
{
var json = _yqlService.FetchCompanies(industryId);
var jobj = JObject.Parse(json);
jobj = JObject.Parse(jobj["query"]["results"]["industry"].ToString());
industry = Helper.DeserializeJson<IndustryModel>(jobj);
industry.Company.ForEach(x => x.SectorId = industry.Id);
db.Find()
SaveIndustry(industry);
}
return industry;
}
}
示例5: GetQuote
public QuoteModel GetQuote(string symbol)
{
using (var db = new DataStore<QuoteModel>("quotes"))
{
var quote = db.GetCollection().Where(x => x.Symbol == symbol).FirstOrDefault();
if (quote == null)
{
var json = _yqlService.FetchQuote(symbol);
var jobj = JObject.Parse(json);
quote = Helper.DeserializeJson<QuoteModel>(JObject.Parse(jobj["query"]["results"]["quote"].ToString()));
SaveQuote(quote);
}
return quote;
}
}