Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
195
UltraWinGrid how to add new item to list (Entity Framework)
posted

I can add new row (item to list), by converting it to BindingList (simple list raises exception)

But when I save context - changes are not being committed / saved to DB

Can you please advise how to archive that?

My code:



            // Flutent API
            var p_fluent = context.Products
                                        .Where (p => p.Price > 5)
                                        .OrderBy (p=> p.Name  ).ThenBy(p => p.Id)
                                        .ToList();

            var listBinding = new BindingList<Product> (p_linq.ToList ());
            

            grdMain.DataSource = listBinding;

Parents
  • 34810
    Offline posted

    Hello Maciej,

    Thank you for your post on this matter.

    I believe the reason that your changes are not being committed or saved to the database is because you are creating a new instance of BindingList<Product> from your p_linq, so that is getting rid of the link to the context and you would need to push the updates back to the context this way. Some events on the grid that can help you do this could be the AfterCellUpdate/AfterRowUpdate.

    I am curious of the exception you are seeing when trying to use a List in this case though, as this should be valid. Can you please provide some more information on that?

Reply Children