Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ed0b60d

Browse filesBrowse files
Samuel CorderSamuel Corder
Samuel Corder
authored and
Samuel Corder
committed
Fixed problem generating illegal instruction
1 parent 15a54d6 commit ed0b60d
Copy full SHA for ed0b60d

File tree

1 file changed

+19
-12
lines changed
Filter options

1 file changed

+19
-12
lines changed

‎MongoDBDriver/Collection.cs

Copy file name to clipboardExpand all lines: MongoDBDriver/Collection.cs
+19-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public class Collection : IMongoCollection
1515

1616

1717
private Connection connection;
18-
private Database db;
1918

2019
private string name;
2120
public string Name {
@@ -41,13 +40,19 @@ public CollectionMetaData MetaData {
4140
}
4241
}
4342

44-
43+
private Database db;
44+
private Database Db{
45+
get{
46+
if(db == null)
47+
db = new Database(this.connection, this.dbName);
48+
return db;
49+
}
50+
}
4551
public Collection(string name, Connection conn, string dbName)
4652
{
4753
this.name = name;
4854
this.connection = conn;
4955
this.dbName = dbName;
50-
this.db = new Database(this.connection, this.dbName);
5156
}
5257

5358
/// <summary>
@@ -101,7 +106,7 @@ public ICursor Find(Document spec, int limit, int skip, Document fields) {
101106
/// A <see cref="MapReduce"/>
102107
/// </returns>
103108
public MapReduce MapReduce(){
104-
return new MapReduce(db, this.Name);
109+
return new MapReduce(this.Db, this.Name);
105110
}
106111

107112
public MapReduceBuilder MapReduceBuilder(){
@@ -125,7 +130,7 @@ public long Count(){
125130
public long Count(Document spec){
126131
try{
127132
//Database db = new Database(this.connection, this.dbName);
128-
Document ret = db.SendCommand(new Document().Append("count",this.Name).Append("query",spec));
133+
Document ret = this.Db.SendCommand(new Document().Append("count",this.Name).Append("query",spec));
129134
double n = (double)ret["n"];
130135
return Convert.ToInt64(n);
131136
}catch(MongoCommandException){
@@ -150,7 +155,7 @@ public void Insert(Document doc){
150155
}
151156

152157
public void Insert (IEnumerable<Document> docs, bool safemode){
153-
if(safemode)db.ResetError();
158+
if(safemode)this.Db.ResetError();
154159
this.Insert(docs);
155160
CheckPreviousError(safemode);
156161
}
@@ -258,10 +263,6 @@ public void Update(Document doc, Document selector, int flags){
258263
this.Update(doc,selector,(UpdateFlags)flags);
259264
}
260265

261-
262-
public void UpdateAll (Document doc, Document selector, bool safemode){
263-
throw new System.NotImplementedException();
264-
}
265266
/// <summary>
266267
/// Runs a multiple update query against the database. It will wrap any
267268
/// doc with $set if the passed in doc doesn't contain any '$' ops.
@@ -284,16 +285,22 @@ public void UpdateAll(Document doc, Document selector){
284285
this.Update(doc, selector, UpdateFlags.MultiUpdate);
285286
}
286287

288+
289+
public void UpdateAll (Document doc, Document selector, bool safemode)
290+
{
291+
throw new System.NotImplementedException();
292+
}
293+
287294

288295
private void CheckError(bool safemode){
289296
if(safemode){
290-
Document err = db.GetLastError();
297+
Document err = this.Db.GetLastError();
291298
if(ErrorTranslator.IsError(err)) throw ErrorTranslator.Translate(err);
292299
}
293300
}
294301
private void CheckPreviousError(bool safemode){
295302
if(safemode){
296-
Document err = db.GetPreviousError();
303+
Document err = this.Db.GetPreviousError();
297304
if(ErrorTranslator.IsError(err)) throw ErrorTranslator.Translate(err);
298305
}
299306
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.