scope problem

2 posts, 0 answers
  1. Zbigniew Kozłowski
    Zbigniew Kozłowski avatar
    60 posts
    Member since:
    Apr 2010

    Posted 14 Jul 2010 Link to this post

    Hi, ive got and error and dont know how to fix it, mine code is:

    IObjectScope scope = DBProvider.GetNewObjectScope();
                var messageQuery = from m in scope.Extent<Messageaccess>()
                                   where m.UsersLOGIN.Equals(Settings.UserLogin)
                                         && m.ShowAlert == Enums.YesNo.Yes
                                         && m.Message.Type == Enums.MessageType.Email
                                   select m;
                int messageCount = messageQuery.Count();
                if (messageCount > 0)
                    int x = 0;
                    string content = string.Empty;
                    foreach (Messageaccess messageAccess in messageQuery)
                        if (x == 0)
                            content = "<html><b>" + messageAccess.Message.Sender + "</b><br><i>" + messageAccess.Message.Subject + "</i></html>";
                        InvokeFunc(messageAccess.Type, messageAccess.Status, messageAccess.SubFolder, false);
                        messageAccess.ShowAlert = Enums.YesNo.No;
                        catch (Exception ex)

    but i got all the time:
    Transaction was terminated before result set is discarded

    The funniest thing is when the query get only like 5 items its working, but when i got lik 200 its not, and i dont know how to fix this.
  2. Jan Blessenohl
    Jan Blessenohl avatar
    707 posts

    Posted 14 Jul 2010 Link to this post

    Hi Zbigniew Kozłowski,
    The query result is a cursor on server side, we fetch only 50 at once. Now the transaction.Commit will (dependent on the type of backend) invalidate the cursor which leads to your exception. To avoid the exception please add a messageQuery.ToList() that will fully retrieve the result.

    Kind regards,
    Jan Blessenohl
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top