Can CLR objects be updated from the Grid?
Options
I tacked this question on another on the forum, but I feel it deserves its own topic.
Is it possible to have a two-way binding towards the grid from a CLR object?
Is it possible to have a two-way binding towards the grid from a CLR object?
Comments
-
it's possible, but this API is internal and not extensible.
vote -
Thank you. Do you have any snippets or something that demonstrates a wrapping around an integer value or something where this is achieved?
-
It's not possible right now. I could enable it, but I'm not sure how to avoid the confusion between editing database objects and editing CLR objects.
-
i need this to edit database objects (but from DataObjects.Net driver)
-
I was able to force linqpad to edit entities. This code contains a lot of hacks, but works
I will publish code soon
-
You mean that you got your own code executing when the user attempted to edit values in the regular output LINQPad grid? Cool.
-
sorry forgot about this.
1. generate wrappers for your types in DataContextDriver.GetSchemaAndBuildAssembly with MS LINQ to SQL attrubutes Table and Column (or you can create wrappers manually/dynamically or apply this attributes to your original types)
2. create class inherited from LINQPad.DataContextBase, override it method SubmitChanges.
3. In DataContextDriver.InitializeContext (or in user code before dumping) set instance of your DataContext to property Util.CurrentDataContext via reflection.
4. wrap objects in DataContextDriver.DisplayObjectInGrid (or in your user code before dumping, but in this case you must wrap it recursively) and attach to your DataContext . Wrapping is not required when original types with this attributes.
5. Save changes in your DataContext.SubmitChanges
see sample in my driver code
http://dolinqpad.codeplex.com/SourceControl/latest -
Awesome. I'll be checking it out immediately.