Error trying to show a result in a gridview

5 posts, 1 answers
  1. Nigel
    Nigel avatar
    10 posts
    Member since:
    Jul 2008

    Posted 16 Feb 2009 Link to this post

    Hi, I am just starting with OpenAccess and thought the first thing to try would be to output some information into a gridview. But I am getting the following error:

    Any operation that will fully resolve the query may not be called once a 'get' operation was performed

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Telerik.OpenAccess.Exceptions.InvalidOperationException: Any operation that will fully resolve the query may not be called once a 'get' operation was performed

    Source Error:

    Line 76: 
    Line 77:             RadGrid1.DataSource = result;
    Line 78:             RadGrid1.DataBind();
    Line 79:         }
    Line 80: 

    Source File: C:\Project Files\IC-Solutions\IC-Solutions\IC-Solutions\Default.aspx.cs    Line: 78

    Stack Trace:

    [InvalidOperationException: Any operation that will fully resolve the query may not be called once a 'get' operation was performed]
       Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e) +28
       Telerik.OpenAccess.RT.ExceptionWrapper.Throw() +34
       OpenAccessRuntime.DataObjects.ForwardQueryResult.resolve() +117
       OpenAccessRuntime.DataObjects.ForwardQueryResult.get_Count() +107
       Telerik.OpenAccess.RT.ListEnumerator.get_Count() +42
       Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +2136
       Telerik.Web.UI.GridResolveEnumerable.Initialize() +55
       Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +40
       Telerik.Web.UI.GridResolveEnumerable.get_DataTable() +31
       Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +222
       Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +155
       Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +556
       Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +219
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +73
       System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
       Telerik.Web.UI.GridTableView.PerformSelect() +28
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
       Telerik.Web.UI.GridTableView.DataBind() +365
       Telerik.Web.UI.RadGrid.DataBind() +165
       IC_Solutions._Default.Button2_Click(Object sender, EventArgs e) in C:\Project Files\IC-Solutions\IC-Solutions\IC-Solutions\Default.aspx.cs:78
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    

    The page looks like this:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using SiteDataObjects;
    using Telerik.OpenAccess;

    namespace IC_Solutions
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {

            }

            protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                /*IObjectScope scope = ObjectScopeProvider1.ObjectScope();
                scope.Transaction.Begin();
                IQueryResult result = scope.GetOqlQuery("Select * from ProductExtent AS x").Execute();
                RadGrid1.DataSource = result;
                scope.Transaction.Rollback();*/
            }

            protected void Button2_Click(object sender, EventArgs e)
            {
                IObjectScope scope = ObjectScopeProvider1.ObjectScope();
                IQueryResult result = scope.GetOqlQuery("Select * from ProductExtent AS x where x.ProductTitle Like $1").Execute("*" + TextBox1.Text +"*" );

                RadGrid1.DataSource = result;
            }


        }
    }

    And a Product looks like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.OpenAccess;

    namespace SiteDataObjects
    {
        [Persistent]
        public class Product
        {
            public long productID;
            public string ProductTitle;
            public string ProductShortDescription;
            public string ProductDetails;

            public ManufacturerManufacturer;
            public Category Category;

            public IList<SupplierProduct> SupplierItems = new List<SupplierProduct>();

            public TaxCode Tax;

            public IList<Product> RelatedProducts = new List<Product>();

       }

    Any ideas?

    Thanks in advanced
  2. Answer
    Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 16 Feb 2009 Link to this post

    Hello Nigel,
    The queries are optimized for sequential reads by default. Please set the IQuery.ForwardOnly property to False, to allow non-sequential operations (probably what the grid does internally) and the error should disappear.
    Hope that helps.

    Greetings,
    Dimitar Kapitanov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Nigel
    Nigel avatar
    10 posts
    Member since:
    Jul 2008

    Posted 16 Feb 2009 Link to this post

    That got it, thanks heaps
  5. Awais
    Awais avatar
    5 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2009 Link to this post

    Can You Please tell me, Where i can set this Property (Iquery.ForwardOnly) to FALSE...


  6. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 03 Mar 2009 Link to this post

    Hello Awais,
    There are three ways to do it, it is dependent on the query api you are using:

                // 1.  
                IQuery q = scope.GetOqlQuery("select * from PersonExtent");  
                q.ForwardsOnly = false;  
                IQueryResult r = q.Execute();  
     
                // 2.  
                var r = from p in scope.Extent<Person>() select p;  
                r.ForwardsOnly = false;  
     
                //3.  
                scope.GetOqlQuery<Person>().ExecuteList();  
     

    Kind regards,
    Jan Blessenohl
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner