Skip to content

Commit

Permalink
Merge pull request #21 from xyq10612/master
Browse files Browse the repository at this point in the history
Fix bug: mongodb查询结果未判空,导致反序列化异常
  • Loading branch information
jarjin authored Feb 21, 2021
2 parents 5e37156 + 20616bf commit eb3a59d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion FirServer/FirServer/Utility/MongoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public T SelectOne<T>(string collectionName, ProjectionDefinition<T> projection,
}
var collection = mDatabase.GetCollection<T>(collectionName);
var result = collection.Find(filter).Project(projection).FirstOrDefault();
return BsonSerializer.Deserialize<T>(result);
return result != null ? BsonSerializer.Deserialize<T>(result) : default(T);
}

public async Task<List<T>> SelectAsync<T>(string collectionName, Expression<Func<T, bool>> filter)
Expand Down

0 comments on commit eb3a59d

Please sign in to comment.