本文整理汇总了C#中MongoCollection.FindAllAs方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.FindAllAs方法的具体用法?C# MongoCollection.FindAllAs怎么用?C# MongoCollection.FindAllAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection.FindAllAs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CoverDB
public static void CoverDB(string player, MongoCollection oldPlayer, MongoCollection newPlayer)
{
Console.WriteLine("正在合并:" + player);
int show = 0;
int count = 0;
var dates = oldPlayer.FindAllAs<BsonDocument>();
foreach (var v in dates)
{
BsonValue key;
if (v.TryGetValue("_id", out key))
{
if (newPlayer.Count(Query.EQ("_id", key)) <= 0)
{
count++;
newPlayer.Save(v);
}
}
show++;
if (show % 1000 == 0)
{
Console.WriteLine("正在合并:" + show);
}
}
Console.WriteLine(player + ":" + count);
}
示例2: ExportToFile
/// <summary>
/// ExportToFile
/// </summary>
/// <param name="currentDataViewInfo"></param>
/// <param name="excelFileName"></param>
/// <param name="exportType"></param>
/// <param name="mongoCol"></param>
public static void ExportToFile(DataViewInfo currentDataViewInfo,
string excelFileName,
EnumMgr.ExportType exportType,
MongoCollection mongoCol)
{
MongoCursor<BsonDocument> cursor;
//Query condition:
if (currentDataViewInfo != null && currentDataViewInfo.IsUseFilter)
{
cursor = mongoCol.FindAs<BsonDocument>(
QueryHelper.GetQuery(currentDataViewInfo.MDataFilter.QueryConditionList))
.SetFields(QueryHelper.GetOutputFields(currentDataViewInfo.MDataFilter.QueryFieldList))
.SetSortOrder(QueryHelper.GetSort(currentDataViewInfo.MDataFilter.QueryFieldList));
}
else
{
cursor = mongoCol.FindAllAs<BsonDocument>();
}
var dataList = cursor.ToList();
switch (exportType)
{
case EnumMgr.ExportType.Excel:
//ExportToExcel(dataList, ExcelFileName);
GC.Collect();
break;
case EnumMgr.ExportType.Text:
ExportToJson(dataList, excelFileName, MongoHelper.JsonWriterSettings);
break;
case EnumMgr.ExportType.Xml:
break;
}
MongoHelper.OnActionDone(new ActionDoneEventArgs(" Completed "));
}
示例3: Intialize
public static void Intialize()
{
_collection = Store.TagCollection();
foreach (var found in _collection.FindAllAs<BsonDocument>())
{
var id = found["_id"].AsInt32;
_tags.Add(found["name"].AsString, id);
if (id > _id) { _id = id; }
}
}
示例4: getProveedores
public List<Proveedor> getProveedores()
{
try
{
coleccion = bd.GetCollection<Proveedor>("Proveedor");
MongoCursor<Proveedor> cursor = coleccion.FindAllAs<Proveedor>();
return cursor.ToList<Proveedor>();
}
catch (Exception E)
{
this.mensaje.Append(E.Message);
}
return null;
}
示例5: Run
/// <summary>
/// 运行
/// </summary>
/// <returns></returns>
public override int Run()
{
_processCollection = (MongoCollection)PlugObj;
if (RuntimeMongoDbContext.CollectionFilter.ContainsKey(_processCollection.Name))
{
var filter = RuntimeMongoDbContext.CollectionFilter[_processCollection.Name].QueryConditionList;
Export(_processCollection.FindAs<BsonDocument>(QueryHelper.GetQuery(filter)).ToList(), _processCollection.Name);
}
else
{
Export(_processCollection.FindAllAs<BsonDocument>().ToList(), _processCollection.Name);
}
MessageBox.Show(_processCollection.Name);
return Success;
}
示例6: ExportToFile
/// <summary>
/// ExportToFile
/// </summary>
/// <param name="currentDataViewInfo"></param>
/// <param name="excelFileName"></param>
/// <param name="exportType"></param>
/// <param name="mongoCol"></param>
public static void ExportToFile(DataViewInfo currentDataViewInfo,
string excelFileName,
EnumMgr.ExportType exportType,
MongoCollection mongoCol)
{
MongoCursor<BsonDocument> cursor;
cursor = mongoCol.FindAllAs<BsonDocument>();
var dataList = cursor.ToList();
switch (exportType)
{
case EnumMgr.ExportType.Text:
ExportToJson(dataList, excelFileName, MongoHelper.JsonWriterSettings);
break;
case EnumMgr.ExportType.Excel:
case EnumMgr.ExportType.Xml:
break;
}
MongoHelper.OnActionDone(new ActionDoneEventArgs(" Completed "));
}
示例7: GetCollectionSchame
/// <summary>
/// 通过读取N条记录来确定数据集结构
/// </summary>
/// <param name="mongoCol">数据集</param>
/// <returns></returns>
public static List<String> GetCollectionSchame(MongoCollection mongoCol)
{
int CheckRecordCnt = 100;
var _ColumnList = new List<String>();
var _dataList = new List<BsonDocument>();
_dataList = mongoCol.FindAllAs<BsonDocument>()
.SetLimit(CheckRecordCnt)
.ToList();
foreach (BsonDocument doc in _dataList)
{
foreach (string item in getBsonNameList(String.Empty, doc))
{
if (!_ColumnList.Contains(item))
{
_ColumnList.Add(item);
}
}
}
return _ColumnList;
}
示例8: ProcessUserCommand
private static void ProcessUserCommand(MongoCollection words)
{
string loweredInput = Console.ReadLine().ToLower();
if (loweredInput == "a")
{
Utilities.SreachWord(words);
}
else if (loweredInput == "b")
{
var dictionary = words.FindAllAs<Word>();
foreach (var word in dictionary)
{
Console.WriteLine(word.Value);
}
}
else if (loweredInput == "c")
{
Utilities.EditWord(words);
}
else if (loweredInput == "d")
{
Utilities.RemoveWords(words);
}
else if (loweredInput == "e")
{
Utilities.AddWord(words);
}
else if (loweredInput == "x")
{
Environment.Exit(0);
}
else
{
Console.WriteLine("Wrong command");
}
}
示例9: Get
protected List<object> Get(MongoCollection<object> collection)
{
return collection.FindAllAs<object>().ToList();
}
示例10: GetCollectionSchame
/// <summary>
/// 通过读取N条记录来确定数据集结构
/// </summary>
/// <param name="mongoCol">数据集</param>
/// <returns></returns>
public static List<string> GetCollectionSchame(MongoCollection mongoCol)
{
var checkRecordCnt = 100;
var columnList = new List<string>();
var dataList = new List<BsonDocument>();
dataList = mongoCol.FindAllAs<BsonDocument>()
.SetLimit(checkRecordCnt)
.ToList();
foreach (var doc in dataList)
{
foreach (var item in GetBsonNameList(string.Empty, doc))
{
if (!columnList.Contains(item))
{
columnList.Add(item);
}
}
}
return columnList;
}
示例11: WriteToSqlLite
private static void WriteToSqlLite(MongoCollection totalExpenses)
{
string conString = @"Data Source=../../../supermarket.db;Version=3;";
var dbSqLiteConnection = new SQLiteConnection(conString);
try
{
dbSqLiteConnection.Open();
var query = totalExpenses.FindAllAs<ExpenseByName>()
.Where(x => x.Date.ToString("MM-yyyy") == "06-2013")
.Select(y => new { Expenses = y.Expenses, VendorName = y.VendorName });
foreach (var item in query)
{
string commandText = String.Format(@"INSERT INTO TotalExpenses VALUES(""{0}"",{1});", item.VendorName, item.Expenses);
SQLiteCommand cmd = new SQLiteCommand(commandText, dbSqLiteConnection);
var result = cmd.ExecuteNonQuery();
}
}
catch (SQLiteException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
dbSqLiteConnection.Close();
}
}