Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • I have a simple grid that is connected to database via LinqInstantFeedbackSource. When form is first shown, _GetQueryable event is fired and data is visible in the grid

                                    protected void lifsZadatak_GetQueryable(object sender, DevExpress.Data.Linq.GetQueryableEventArgs e)
                                    {
                                    db = new PrimaEntities();
                                    var q = db.Zadatci.AsQueryable();

                                    e.QueryableSource = q;
                                    e.Tag = db;

                                    }

                                    Now, when I change data in database with some third program (SQL Server Management Studio) I can’t get this updates visible in my grid

                                    I tried:

                                    gridViewMain.RefreshData();
                                    grdMain.RefreshDataSource();
                                    lifsZadatak.Refresh();


                                    Please tell me what I should do to get this updates

                                    Test project is attached

                                TestServerMode.zip
                                You must  log in  or  register  to leave comments

                                2 Solutions

                                Creation Date Rating Importance Sort by
                                0

                                I was completely wrong when I thought that _GetQueryable is called every time LinqInstantFeedbackSource needs data. It is called just once and it use that queryable source all the time. That is way my code is not working properly

                                Instead of:

                                db = new PrimaEntities();
                                var q = db.Zadatci.AsQueryable();
                                e.QueryableSource= q;

                                (which is ok if _GetQueryable is called multiple times)

                                It shoud be:

                                db = new PrimaEntities();
                                var objectContext = ((IObjectContextAdapter)db).ObjectContext;
                                var objectSetZadatak = objectContext.CreateObjectSet<Zadatak>();
                                objectSetZadatak.MergeOption = MergeOption.OverwriteChanges;
                                var q = objectSetZadatak.AsQueryable();
                                e.QueryableSource = q;

                                (this is the way to refresh data with Entity Framework, you have to use ObjectContext)

                                • Andrew Ser (DevExpress Support) 03.27.2013

                                  Hi,
                                      I'm glad to hear that you have resolved this issue. Please feel free to contact us if you have any difficulties.

                                You must  log in  or  register  to leave comments
                                0

                                Hello,
                                We have discussed a similar issue in the How to reload data on LinqInstantFeedbackSource thread. Please review it.
                                Does this link help you find an answer? I hope to hear from you soon.

                                • Dragutin Vdović 03.27.2013

                                  I saw the article you are referring to (How to reload data on LinqInstantFeedbackSource) and my code in _GetQueryable function will always return refreshed and complete set of data (as described in http://stackoverflow.com/questions/2564265/entity-framework-refresh-objects-from-database) but problem is that _GetQueryable is run only once when form is created.

                                  None of this:
                                  gridViewMain.RefreshData();
                                  grdMain.RefreshDataSource();
                                  lifsZadatak.Refresh();
                                  will trigger it again

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners