deanlee17
asked on
Entity Data Model saving data
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 GetWPFtblSmartQuoteHeaders Query(OMSy stemEntiti es As hello.OMSystemEntities) As System.Data.Objects.Object Query(Of hello.WPFtblSmartQuoteHead er)
Dim WPFtblSmartQuoteHeadersQue ry As System.Data.Objects.Object Query(Of hello.WPFtblSmartQuoteHead er) = OMSystemEntities.WPFtblSma rtQuoteHea ders
'Update the query to include WPFtblSmartQuoteLines data in WPFtblSmartQuoteHeaders. You can modify this code as needed.
WPFtblSmartQuoteHeadersQue ry = WPFtblSmartQuoteHeadersQue ry.Include ("WPFtblSm artQuoteLi nes")
'Returns an ObjectQuery.
Return WPFtblSmartQuoteHeadersQue ry
End Function
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEvent Args) Handles MyBase.Loaded
Dim OMSystemEntities As hello.OMSystemEntities = New hello.OMSystemEntities()
'Load data into WPFtblSmartQuoteHeaders. You can modify this code as needed.
Dim WPFtblSmartQuoteHeadersVie wSource As System.Windows.Data.Collec tionViewSo urce = CType(Me.FindResource("WPF tblSmartQu oteHeaders ViewSource "), System.Windows.Data.Collec tionViewSo urce)
Dim WPFtblSmartQuoteHeadersQue ry As System.Data.Objects.Object Query(Of hello.WPFtblSmartQuoteHead er) = Me.GetWPFtblSmartQuoteHead ersQuery(O MSystemEnt ities)
WPFtblSmartQuoteHeadersVie wSource.So urce = WPFtblSmartQuoteHeadersQue ry.Execute (System.Da ta.Objects .MergeOpti on.AppendO nly)
End Sub
Many Thanks.
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 GetWPFtblSmartQuoteHeaders
Dim WPFtblSmartQuoteHeadersQue
'Update the query to include WPFtblSmartQuoteLines data in WPFtblSmartQuoteHeaders. You can modify this code as needed.
WPFtblSmartQuoteHeadersQue
'Returns an ObjectQuery.
Return WPFtblSmartQuoteHeadersQue
End Function
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEvent
Dim OMSystemEntities As hello.OMSystemEntities = New hello.OMSystemEntities()
'Load data into WPFtblSmartQuoteHeaders. You can modify this code as needed.
Dim WPFtblSmartQuoteHeadersVie
Dim WPFtblSmartQuoteHeadersQue
WPFtblSmartQuoteHeadersVie
End Sub
Many Thanks.
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellen, Cheers mate.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=563
http://ollysense.blogspot.co.uk/2010/10/wpf-datagrid-entity-framework-40.html
http://stackoverflow.com/questions/2700792/2-way-databinding-with-entity-framework-and-wpf-datagrid