Click here to Skip to main content
15,890,690 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 2:08
professionalEddy Vluggen11-Dec-18 2:08 
GeneralRe: Fill Treeview using recursion Pin
sterenas11-Dec-18 5:34
sterenas11-Dec-18 5:34 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 6:16
professionalEddy Vluggen11-Dec-18 6:16 
GeneralRe: Fill Treeview using recursion Pin
sterenas11-Dec-18 7:51
sterenas11-Dec-18 7:51 
GeneralRe: Fill Treeview using recursion Pin
Eddy Vluggen11-Dec-18 23:10
professionalEddy Vluggen11-Dec-18 23:10 
Questionentity framework Group by multiple columns and count the number of groups with more than 1 item Pin
desanti6-Dec-18 11:24
desanti6-Dec-18 11:24 
AnswerRe: entity framework Group by multiple columns and count the number of groups with more than 1 item Pin
Richard Deeming7-Dec-18 7:46
mveRichard Deeming7-Dec-18 7:46 
QuestionProblems with Entity Famework and bindingsources Pin
desanti6-Dec-18 0:13
desanti6-Dec-18 0:13 
Hello !
i'm using vb.net 2017 with EF 6
I have 2 tables on my database : Product and ProductDetail
I have also 2 bindingsource Productbindingsource and ProductDetailsbindingsource.
I have also 2 datagridview each of them bound to the respective bindingsource.
When the user select a product in the first datagridview , the other datagridview is filled with Productdetails for the selected product.
I have this code :

Private sub Fill_Product
context.Products.Where(Function(t2) t2.cl>5).Load
ProductBindingsource.datasource=context.Products.Local.ToBindinglist
End sub

Private Sub ProductBindingSource_CurrentChanged(sender As Object, e As  EventArgs) Handles ProductBindingSource.CurrentChanged

context.Entry(ProductBindingSource.Current).Collection("ProductDetails").Load()
    ProductDetailsBindingsource.Datasource=DirectCast(ProductBindingSource.Current, Product).ProductDetails
End sub

  Private Sub RollBack()
    Dim changedEntries = context.ChangeTracker.Entries().Where(Function(x) x.State <> EntityState.Unchanged).ToList()
    For Each entry In changedEntries

        Select Case entry.State
            Case EntityState.Modified
                entry.CurrentValues.SetValues(entry.OriginalValues)
                entry.State = EntityState.Unchanged
            Case EntityState.Added
                entry.State = EntityState.Detached
            Case EntityState.Deleted
                entry.State = EntityState.Unchanged
        End Select
    Next
End Sub


I have 2 problems with this code :
1.when I delete a ProductDetail from the second Grid , and after execute the rollback Sub , the deleted ProductDetail is not back on that datagrid , andalso when I add new Productdetail when I rollback this is not removed from the gridview.( other modifications in values , are reverted to original values).

2.On the sub ProductBindingSource_CurrentChanged , everytime that the user select a product in the first grid , the second grid is filled with ProductDetails and database is queried with .Load. But this is ok when the user select a Product for the first time . What about when the user select a Product for the second or third time ? The product Details are already loaded , so what to do to not query again from database but use local data ?
Thank you !

modified 6-Dec-18 7:17am.

QuestionDrawlines is correct or not ? Pin
Coffee_Break5-Dec-18 1:27
Coffee_Break5-Dec-18 1:27 
AnswerRe: Drawlines is correct or not ? Pin
Eddy Vluggen5-Dec-18 2:05
professionalEddy Vluggen5-Dec-18 2:05 
Questionsave my excel invoice in excel sheet Pin
kami1244-Dec-18 8:04
kami1244-Dec-18 8:04 
QuestionRe: save my excel invoice in excel sheet Pin
Richard MacCutchan4-Dec-18 8:58
mveRichard MacCutchan4-Dec-18 8:58 
QuestionError ContextSwitchDeadlock Pin
desanti4-Dec-18 5:33
desanti4-Dec-18 5:33 
AnswerRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen4-Dec-18 6:33
professionalEddy Vluggen4-Dec-18 6:33 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti4-Dec-18 8:45
desanti4-Dec-18 8:45 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen4-Dec-18 9:37
professionalEddy Vluggen4-Dec-18 9:37 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 1:18
desanti5-Dec-18 1:18 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 1:43
professionalEddy Vluggen5-Dec-18 1:43 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 2:08
desanti5-Dec-18 2:08 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 2:37
professionalEddy Vluggen5-Dec-18 2:37 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 2:49
desanti5-Dec-18 2:49 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 2:52
professionalEddy Vluggen5-Dec-18 2:52 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 2:59
desanti5-Dec-18 2:59 
GeneralRe: Error ContextSwitchDeadlock Pin
Eddy Vluggen5-Dec-18 3:01
professionalEddy Vluggen5-Dec-18 3:01 
GeneralRe: Error ContextSwitchDeadlock Pin
desanti5-Dec-18 3:05
desanti5-Dec-18 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.