QDSCV Adding multiple items

3 posts, 0 answers
  1. Peter
    Peter avatar
    28 posts
    Member since:
    Oct 2006

    Posted 27 Nov 2011 Link to this post

    Hi,

    I am using QDSCV in my code-behind to manage my data. In the containing class I wrote a method, that is called multiple times and uses AddNew(object) method, to add new items to the collection. When I add only one element it submits properly afterwards. But as soon as I add two or more elements the collection gets into submit mode and does not return. There is no exception but when I close and reopen the program I see that the changes have not been submitted.

    This is the executed code (first AddSubscription is executed and afterwards I call SubmitSubscriptions):

    public void AddSubscription(pcProject project)
    {
        if(project == null)
        {
            return;
        }
     
        var subscription = (pcSubscription) subscriptions.AddNew();
        subscription.pcUser = users.CurrentItem as pcUser;
        subscription.pcProject = project;
    }
    public void SubmitSubscriptions()
    {
        subscriptions.SubmitChanges();
    }

    Perhaps you can give me a clue how to get this working with more than one element at a time.

    Best regards,
    Peter Schmidt
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 28 Nov 2011 Link to this post

    Hello Peter,

    Can you please send us a small sample project that demonstrates this. You can use a sampe DB such as Northwind or AdventureWorks for the purpose of demonstration.

    Once we have a runnable project that we can debug, we will be able to see what is going on.

    Thanks in advance.

    Best wishes,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Peter
    Peter avatar
    28 posts
    Member since:
    Oct 2006

    Posted 28 Nov 2011 Link to this post

    Hi Ross,

    I tried some different things today and found out that there are multiple items with ID 0 added. This might have caused the problem with my datamodel. The strange thing is that there was no error at all. The application just stopped changing the database. As pcSubscription is a reference to a different entity I added it to the user itself instead of the subscriptions source. Now it is working fine. Sorry for the inconvenience.

    Best wishes,
    Peter
Back to Top