-
Type:
Task
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.9
-
Component/s: Documentation
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Hello.
I've been stuck for a couple of days trying to save a Chunk. I have not been able to find a single sample of this anywhere in your documentation, or online. Can you please point to a good resource?
I have an object in memory. I need to wrap something with an ID around it and save it to a chunk. I've done that with a wrapper class, and the code to save seems to work. On deserializing, the query for that ID returns null. I have not found any samples of saving and retrieving a chunk anywhere.
Thank you - any suggestions would be appreciated.
My code to save the chunk:
var connectionString = Properties.Settings.Default.DBConnectionString ;
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase(DBName);
var gfsPhoto = new MongoGridFS(server, DBName, new MongoGridFSSettings());
var MC = new MongoChunk(Value);
gfsPhoto.Chunks.Save(MC);
MongoChunk has two properties:
public Guid Id;
public object Value;
I'm trying this to retrieve the data, but Ch returns null:
var gfsPhoto = new MongoGridFS(server, DBName, new MongoGridFSSettings());
var Ch = gfsPhoto.Chunks.FindOne(Query.EQ("_id", MC.ID));
CP.Value = Ch.GetValue(1); //not sure if this line is correct either - it's not hit due to the current error
Thank you,
Anatoly
- is duplicated by
-
CSHARP-949 Follow up on CSHARP-947
-
- Closed
-