コード例 #1
0
ファイル: Concurrency.cs プロジェクト: otdelBA/LiteDB
 static void Assert()
 {
     // checks if datafile are ok
     using (var db = new LiteEngine(filename))
     {
         db.FindAll("collection").ToArray();
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: zdbobi/LiteDB
        static void Main(string[] args)
        {
            var orig = @"C:\Git\LiteDB\LiteDB.Shell\bin\Debug\net40\teste.db";



            using (var db = new LiteEngine(orig))
            {
                var col = db.GetCollectionNames().First();

                var tt = db.FindAll(col).ToArray();

                var c = db.FindOne("DataObjects_1", Query.EQ("_id", "qyeyeW.1oMJK5"));



                Console.WriteLine(c == null);
            }
            //{
            //    // reading all database
            //    foreach (var col in db.GetCollectionNames())
            //    {
            //        Console.WriteLine("Collection: " + col);
            //
            //
            //        foreach (var doc in db.Find(col, Query.All("Token.LastUsedOn")).Take(10))
            //        {
            //            Console.WriteLine(JsonSerializer.Serialize(doc, true));
            //            // ok
            //        }
            //    }
            //}


            Console.WriteLine("End.");
            Console.ReadKey();
        }
コード例 #3
0
        internal void ParseCollection(TreeNode rootNode, string fileName, string password = "")
        {
            using (LiteEngine engine = new LiteEngine(fileName, password))
            {
                List <BsonDocument> docs = engine.FindAll(rootNode.Text).ToList();
                docs.ForEach(d =>
                {
                    switch (d.Type)
                    {
                    case BsonType.MinValue:
                        rootNode.Nodes.Add(new TreeNode("MinValue"));
                        break;

                    case BsonType.Null:
                        rootNode.Nodes.Add(new TreeNode("Null"));
                        break;

                    case BsonType.Int32:
                        rootNode.Nodes.Add(new TreeNode(d.AsInt32.ToString()));
                        break;

                    case BsonType.Int64:
                        rootNode.Nodes.Add(new TreeNode(d.AsInt64.ToString()));
                        break;

                    case BsonType.Double:
                        rootNode.Nodes.Add(new TreeNode(d.AsDouble.ToString()));
                        break;

                    case BsonType.Decimal:
                        rootNode.Nodes.Add(new TreeNode(d.AsDecimal.ToString()));
                        break;

                    case BsonType.String:
                        rootNode.Nodes.Add(new TreeNode(d.AsString));
                        break;

                    case BsonType.Document:
                        ParseDocument(rootNode, d.AsDocument);
                        break;

                    case BsonType.Array:
                        rootNode.Nodes.Add(new TreeNode("Array"));
                        break;

                    case BsonType.Binary:
                        rootNode.Nodes.Add(new TreeNode("Binary"));
                        break;

                    case BsonType.ObjectId:
                        rootNode.Nodes.Add(new TreeNode(d.AsObjectId.ToString()));
                        break;

                    case BsonType.Guid:
                        rootNode.Nodes.Add(new TreeNode(d.AsGuid.ToString()));
                        break;

                    case BsonType.Boolean:
                        rootNode.Nodes.Add(new TreeNode(d.AsBoolean.ToString()));
                        break;

                    case BsonType.DateTime:
                        rootNode.Nodes.Add(new TreeNode(d.AsDateTime.ToShortDateString()));
                        break;

                    case BsonType.MaxValue:
                        rootNode.Nodes.Add(new TreeNode("MaxValue"));
                        break;

                    default:
                        break;
                    }
                });
            }
        }