Browse Source

Casual optimize

Lith 8 months ago
parent
commit
2715a24688
2 changed files with 7 additions and 3 deletions
  1. 3 3
      README.md
  2. 4 0
      src/Vitorm.MongoDB/DbContext.cs

+ 3 - 3
README.md

@@ -56,7 +56,7 @@ namespace App
         static void Main2(string[] args)
         {
             // #1 Init
-            using var dbContext = new Vitorm.MongoDB.DbContext("http://localhost:9200");
+            using var dbContext = new Vitorm.MongoDB.DbContext("mongodb://mongoadmin:mongoadminsecret@localhost:27017");
             dbContext.TryDropTable<User>();
             dbContext.TryCreateTable<User>();
             dbContext.Add(new User { id = 1, name = "lith" });
@@ -96,7 +96,7 @@ namespace App
         static void Main(string[] args)
         {
             // #1 Configures Vitorm
-            using var dbContext = new Vitorm.MongoDB.DbContext("http://localhost:9200");
+            using var dbContext = new Vitorm.MongoDB.DbContext("mongodb://mongoadmin:mongoadminsecret@localhost:27017");
 
             // #2 Create Table
             dbContext.TryDropTable<User>();
@@ -189,7 +189,7 @@ dotnet add package Vitorm.MongoDB
       {
         "provider": "MongoDB",
         "namespace": "App",
-        "connectionString": "http://localhost:9200"
+        "connectionString": "mongodb://mongoadmin:mongoadminsecret@localhost:27017"
       }
     ]
   }

+ 4 - 0
src/Vitorm.MongoDB/DbContext.cs

@@ -11,6 +11,10 @@ namespace Vitorm.MongoDB
             this.dbConfig = dbConfig;
         }
 
+        public DbContext(string connectionString) : this(new DbConfig(connectionString))
+        {
+        }
+
 
         #region Transaction
         public virtual IDbTransaction BeginTransaction() => throw new System.NotImplementedException();