Linq to entities / changes done to datagridview not reflected in database
Hello,
I am new to Linq and experience troubles getting following done.
I have a datagridview(grdpricing) which I bind to the result of a Linq to entities query. When I edit the datagridview, the changes are reflected on the grid but as soon as I call a db.savechanges(), it reloads the original content and the updates never reached the database. I have been reading forums for hours but can't seem to pinpoint what I am doing wrong. It seems pretty straigtforward seen I only want to write changes done in a databound grid back to the db.
Thanks for your help.
VS 2010 / mysql
Here I load data into the grid:
Code:
Dim qryPricing = From objProperty In dcVilla.tblpropertydetail
Join objPricing In dcVilla.tblpricing
On objProperty.prop_det_index Equals objPricing.prop_id
Where objProperty.prop_det_Status = True
Where objPricing.prop_state = True
Order By objPricing.prop_rental_single
Select New With {.prop_id = objPricing.prop_id, .prop_rental_single = objPricing.prop_rental_single, .prop_rental_double = objPricing.prop_rental_double, .prop_rental_triple = objPricing.prop_rental_triple, .prop_rental_Quadruple = objPricing.prop_rental_quadruple, .prop_state = objPricing.prop_state, .prop_date_active = objPricing.prop_date_active, .prop_date_inactive = objPricing.prop_date_inactive}
grdPricing.DataSource = qryPricing
grdPricing.AutoGenerateColumns = True
and this code is used on the click event of a button:
Code:
grdPricing.EndEdit()
dcVilla.SaveChanges()
Thanks a lot,
Stijn