This is a migrated thread and some comments may be shown as answers.

scope problem

1 Answer 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zbigniew Kozłowski
Top achievements
Rank 1
Zbigniew Kozłowski asked on 14 Jul 2010, 02:38 PM
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);
 
                    scope.Transaction.Begin();
                    messageAccess.ShowAlert = Enums.YesNo.No;
                    try
                    {
                        scope.Transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        scope.Transaction.Rollback();
                    }
                    x++;
                }
scope.Dispose();

but i got all the time:
Transaction was terminated before result set is discarded
(Telerik.OpenAccess.Exceptions.UnsupportedException)

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.

1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 14 Jul 2010, 03:29 PM
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
Tags
General Discussions
Asked by
Zbigniew Kozłowski
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Share this question
or