Workflow:
I have a winform app with two forms, in the 1st form I query a liteDB
and it manipulates an IEnumerable<T>
instance inside a using
block with retrieved data.
IEnumerable<student> searchResult;
using(var db = new LiteDatabase(@"C:\Temp\MyData.db"))
{
var col = db.GetCollection<student>("students");
col.EnsureIndex(x => x.contact.phone);
searchResult = col.Find(x => x.contact.phone == "123456789");
}
Form2 frm2 = new Form2();
Form2.profileData = searchResult.AtElement(index);
Problem:
I then, need to send an element of searchResult<student>
to 2nd form in order to show user, as you can see in the last 2 lines of above code.
But since it's inside using
block, I get System.ObjectDisposedException
.
Data types and exception:
studentCollection.Find()
:
searchResult
:
Exception:
Addition:
What I already though of as possible way is:
Override and nullify existing dispose()
method then call my own implemented method after I'm done; Which is basically equals to not having a using
block, except that I don't have to take care of disposing other objects in above using
block, but only searchResult<student>
.
P.S: I'm newbie at whole thing, appreciate the help and explanation