Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In our project we are using

-Entity Framework - Repository Pattern + Unit of Work Pattern together + We are using Devexpress controls.

The related part of the code for initializing our grid is:

C#
UOW = new RepositoryObject.Core.UnitOfWork();
repXtraGridAddXtraEditor = new RepositoryObject.DesignLayer.XtraGridViewAddXtraEditorRep(UOW,   true);
XtraGridViewXtraGridEditorList = new   RepositoryObject.DesignLayer.XtraGridViewAddXtraEditorRep(UOW, true).Query(t => t.XtraGridViewId == XtraGridViewId).ToList();
BindingSource bSource = new BindingSource() { DataSource = XtraGridViewXtraGridEditorList};
grdXtraGridAddXtraEditor.DataSource = bSource;


When we delete a row from our grid
C#
// Delete as entity
repXtraGridAddXtraEditor.Delete((BusinessObject.DesignLayer.XtraGridViewAddXtraGridEditor)gvwXtraGridAddXtraEditor.GetFocusedRow());
//reflect changes to DB
UOW.Db.SaveChanges();
// Delete from grid ( from screen)
gvwXtraGridAddXtraEditor.DeleteRow(gvwXtraGridAddXtraEditor.FocusedRowHandle);
//unsure pieces of codes  
bSource.EndEdit();
bSource.ResetBindings(false);


UNLESS we use the BOTH OF DELETES, the delete is not sychronized.

In other words, Grid and ENTITY FRAMEWORK are not aware of each other .

1- Is there something that I am missing ?
2- Is there a better alternative method ?

Thanks all
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900