troubleshooting Question

Entity Data Model saving data

Avatar of deanlee17
deanlee17 asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
4 Comments1 Solution413 ViewsLast Modified:
Hi Experts,

I think im missing something simple. I have created an entity data model that gets filled from an SQL server database, filled 2 datagrids using the tables in the data model. How do I get any changes within the grid to fire back into my SQL server database?

My (generated) code so far is....

 Private Function GetWPFtblSmartQuoteHeadersQuery(OMSystemEntities As hello.OMSystemEntities) As System.Data.Objects.ObjectQuery(Of hello.WPFtblSmartQuoteHeader)

        Dim WPFtblSmartQuoteHeadersQuery As System.Data.Objects.ObjectQuery(Of hello.WPFtblSmartQuoteHeader) = OMSystemEntities.WPFtblSmartQuoteHeaders
        'Update the query to include WPFtblSmartQuoteLines data in WPFtblSmartQuoteHeaders. You can modify this code as needed.
        WPFtblSmartQuoteHeadersQuery = WPFtblSmartQuoteHeadersQuery.Include("WPFtblSmartQuoteLines")
        'Returns an ObjectQuery.
        Return WPFtblSmartQuoteHeadersQuery
    End Function

    Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded

        Dim OMSystemEntities As hello.OMSystemEntities = New hello.OMSystemEntities()
        'Load data into WPFtblSmartQuoteHeaders. You can modify this code as needed.
        Dim WPFtblSmartQuoteHeadersViewSource As System.Windows.Data.CollectionViewSource = CType(Me.FindResource("WPFtblSmartQuoteHeadersViewSource"), System.Windows.Data.CollectionViewSource)
        Dim WPFtblSmartQuoteHeadersQuery As System.Data.Objects.ObjectQuery(Of hello.WPFtblSmartQuoteHeader) = Me.GetWPFtblSmartQuoteHeadersQuery(OMSystemEntities)
        WPFtblSmartQuoteHeadersViewSource.Source = WPFtblSmartQuoteHeadersQuery.Execute(System.Data.Objects.MergeOption.AppendOnly)
    End Sub

Many Thanks.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros