Closed lyquocnam closed 7 years ago
Hello @lyquocnam ,
I apologize, I do not know what CRUB is. Perhaps you might want to look at following RethinkDB tutorial: https://www.rethinkdb.com/docs/guide/java/
WinForm data binding is out of the scope of this driver. If you need help with WinForms data binding, you can find more information about how to bind POCO objects and WinForm controls through Google Search here.
A Microsoft Example: https://msdn.microsoft.com/en-us/library/y0wfd4yz(v=vs.110).aspx
Additionally, if you require more help, please sign-up and use the public RethinkDB Slack / Chat channel. There are many people in the slack chat channel that are willing to help for free. Posting GitHub issues here is normally reserved for changes to source code and/or new features for the driver. If your question cannot be answered, you can tag me @bchavez in Slack chat and we can chat more about help.
Thanks, Brian
:sunny: :crescentmoon: [**"I've been counting down the days and the nights..."**_](https://www.youtube.com/watch?v=uMcYRk_o82M)
@lyquocnam Did you mean CRUD?
@bchavez thanks so much , i will ! @jjonesrs yes CRUD ( create, read, update, delete ) i don't know how to subscibe, get any changes and reload on datagridview. in Vietnam, winform so strong, but realtime not yet. i think rethinkdb this will help.
@lyquocnam Has been a while but something like the following could work. This is code is not tested just off the top of my head but should help you get started.
var bindingList = new BindingList<ObjType>{
AllowNew = true,
AllowRemove = true,
RaiseListChangedEvents = true,
AllowEdit = true
};
var changes = RethinkDB.R.Table("TableName").Changes().OptArg( "include_initial", true ).RunChangesAsync<EventDescriptor>( connection )
new Thread(()=>{
while(changes.MoveNext()){
//Would need to do some more handle delete as NewValue would be null
if(changes.Current.OldValue != null){
var item = bindingList.First(x=>x.Id == changes.Current.NewValue.Id);
//update properties on item (could replace in bindingList)
bindingList.ResetItem(bindingList.IndexOf(item));
}else
bindingList.Add(changes.Current.NewValue);
}
}).Start();
bindingList.AddingNew += new AddingNewEventHandler((obj,e)=>{
//Handle filling of object
e.NewObject = new ObjType();
});
bindingList.ListChanged += new ListChangedEventHandler((obj,e)=>{
switch(e.ListChangedType){
case: ListChangedType.ItemAdded:
//Add to rethinkdb
case: ListChangedType.ItemChanged:
//Update in rethinkdb
case: ListChangedType.ItemDeleted:
//Remove in rethinkdb
default:
//Do nothing
}
});
dataGridView.DataSource = bindingList;
Hopefully should give you some guidence
Hi @lyquocnam ,
ICYMI in slack, here is your CRUD demo. I'll leave the Update
/Delete
parts as an exercise for the reader.
Link: RethinkWinFormsDemo.zip
:car: :police_car: :rotating_light: "Drive it like you stole it..."
Many thanks mr @bchavez and mr @jrote1, demo is work ! this awesome, i will learn and get hard work ! see you soon later. Good day to you ! 👍
Hi author, i read some documents about rethinkdb driver. but i need some sample about CRUB on winform, how to show all document on DataGridView and detect changes on it.
please help ! this really i need !