none
Entity Tables and BindingSource RRS feed

  • Question

  • Hi:

    I'm using a BindingNavigator, it's DataSource property is set to a BindingSource, which in turn has it's DataSource property set to an Entity Table from a DataContext.

    I faced several difficulties with it but I solved them, there's a last issue.

    Suppose I delete an entity from say DB.Customers, using DB.Customers.DeleteOnSubmit(customer) and DB.SubmitChanges(), and later, I create myform with myBindingSource.DataSource = DB.Customers, and a myBindingNavigator.DataSource = myBindingSource, then I find that when navigating through all entities, it suddenly returns empty entities as if it was returning the deleted entities.

    Could anybody tell me what I'm I missing here?

    Thanks in advance.

    Rafael
    Believe you can do it, and you will!!
    Friday, August 21, 2009 1:44 AM

Answers

  • Hi rafsots,

    You can set the BindingSource’s DataSource as query, for example:
    bs.DataSource = from p in context.Stus select p;

    Because the query is using yield return, it will query in the database when you iterate through it.

     

    Or you can delete using BindingSource and call BidingSource.EndEdit(), DB.SubmitChanges() to submit the changes to the database.

     

    Does this works for you? If you have any questions or concerns, please update the thread and we will have a further discussion.

     

     

    Best Regards

    Yichun Feng

     

    • Marked as answer by RalphDev Monday, August 24, 2009 3:11 PM
    Monday, August 24, 2009 9:09 AM