Entity Data Model saving data

deanlee17
deanlee17 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:

Author

Commented:
Blimey, I thought it would be easier than this, i assumed EDM would just keep firing updates into the database....

First link does use ERM but then codes another connection to the database?! I thought when you have an EDM this connection can be used for all database interactions?

second link, no use.

third link, look at it now.
Most Valuable Expert 2012
Top Expert 2014
Commented:

Author

Commented:
Excellen, Cheers mate.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial