Databind r.a.d.grid

14 posts, 2 answers
  1. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 07 Feb 2009 Link to this post

    IObjectScope os = (IObjectScope)Context.Items["ObjectScopeProvider"];  
                IQueryable result = from x in os.Extent<UserRole>()  
                                    where x.PortalID == 1  
                                    select new { x.User.UserID, x.User.Email, x.User.FuldeNavn, x.Medlemsnummer, x.Role.RoleName, x.User.HuskLogon};  
     
    RadGrid1.DataSource = result

    This code will produce a runtime error:

    "from 'System.Int32' til 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'."

    I have traced it to the field(see above): x.User.HuskLogon.

    This field have the type: int?

    If I change it to: int, no error will happen!

    I am not sure if r.a.d.grid causing the trouble or it is OpenAccess.

    Help, anyone?

  2. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 08 Feb 2009 Link to this post

    Hello Hessner,
    Can you show us the stack trace?

    Best wishes,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 08 Feb 2009 Link to this post

    Here are the trace:

    [InvalidCastException: Ugyldig ændring fra 'System.Int32' til 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089]]'.]  
       System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) +7565416  
       System.Int32.System.IConvertible.ToType(Type type, IFormatProvider provider) +36  
       System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +7597264  
       Telerik.OpenAccess.Query.TypedEnumerator`1.Translated(Object c) +865  
       Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.Generic.IEnumerator<T>.get_Current() +220  
       Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.IEnumerator.get_Current() +102  
       Telerik.Web.UI.GridResolveEnumerable.GetCollectionItemType(Boolean noItemsInEnumerator, Type& itemType, Object& firstObject) +249  
       Telerik.Web.UI.GridResolveEnumerable.ParseProperties() +90  
       Telerik.Web.UI.GridResolveEnumerable.Initialize() +13  
       Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +20  
       Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, IEnumerable enumerable, Boolean CaseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +158  
       Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +129  
       Telerik.Web.UI.GridDataSourceHelper.GetResolvedDataSource(GridTableView owner, Object dataSource, String dataMember, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields) +383  
       Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +140  
       Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +33  
       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() +4  
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73  
       Telerik.Web.UI.GridTableView.DataBind() +238  
       Telerik.Web.UI.RadGrid.DataBind() +80  
       Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +2122  
       Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +121  
       System.Web.UI.Control.LoadRecursive() +50  
       System.Web.UI.Control.LoadRecursive() +141  
       System.Web.UI.Control.LoadRecursive() +141  
       System.Web.UI.Control.LoadRecursive() +141  
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627  
     
  5. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 09 Feb 2009 Link to this post

    Should I open a support ticket regarding this issue?
  6. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 09 Feb 2009 Link to this post

    Hi Bo Hessner,

    thanks for reporting this issue to us. It seems as if the problems exists only for nullable type fields that are in a new structure. OpenAccess gets a value but the called .Net framework method is not able to convert to the nullable type.
    I will fix this and the next version will contain the necessary changes.
    You Telerik points have been updated.

    Best wishes,
    Thomas
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 09 Feb 2009 Link to this post

    1. When will next release be?
    2. Can you supply a work around?
  8. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 09 Feb 2009 Link to this post

    Hello Bo Hessner,

    I cannot say yet when the next version will come up, I hope it is not that far away. I will ask my collegue for more information.
    Currently, there is two workaround,s and that is not to
    (a) use a new anonymous type (no projection)
    OR
    (b) not to use a nullable field in the projection.

    Hope this helps,
    Thomas
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 11 Feb 2009 Link to this post

    I will replace OpenAcces in this query,- do you have any more information regarding the next fix-date?
  10. Answer
    Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 13 Feb 2009 Link to this post

    Hi Hessner,
    We wil try to bring out a next patch end of next week.

    Greetings,
    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.
  11. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 21 Feb 2009 Link to this post

    Any chance for a patch this weekend?
  12. Answer
    Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 23 Feb 2009 Link to this post

    Hi Hessner,
    Due to some problems found during the test phase, the SP release is scheduled for tomorrow.

    Best wishes,
    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.
  13. Sathish
    Sathish avatar
    25 posts
    Member since:
    Dec 2008

    Posted 27 Feb 2009 Link to this post

    Hi,

    Just an off the topic question, when you write a query like (the one you showed in your example)

    IObjectScope os = (IObjectScope)Context.Items["ObjectScopeProvider"];  
                IQueryable result = from x in os.Extent<UserRole>()  
                                    where x.PortalID == 1  
                                    select new { x.User.UserID, x.User.Email, x.User.FuldeNavn, x.Medlemsnummer, x.Role.RoleName, x.User.HuskLogon};

    How does it actually work? The architecture behind it. Does it download all the data from UserRole table (from db) and then run the LINQ to filter the results? OR does it actually only retrieve data that matched the criteria from the DB?
  14. Hessner
    Hessner avatar
    189 posts
    Member since:
    Mar 2003

    Posted 27 Feb 2009 Link to this post

    Hi,

    havent seen the actual "raw" SQL query, but I expect a prober select with join and where in the right places.

    As I would do it by hand.

    I expect there are an easy way to "dump" the SQL query, but haven't looked for it - yet.



  15. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 27 Feb 2009 Link to this post

    Hello Bo  & Sathish,

    you can see the SQL excecuted when turning the logging facilities on; this can be done from the OpenAccess menu->Configuration->Backend Configuration Settings.
    As for your other question:
    Currently, the LINQ projection is not pushed to the server. That means, the 'default fetch group' is loaded as if it had been requested by an OQL query 'select * from UserRoleExtent ....'. Later, the LINQ execution is accessing the properties it needs and projects them into a new, non-persistent type instance. That gives also a hint how to avoid loading to many fields: using the DefaultFetchGroupAttribute to set off the loading of fields which are not necessary in this circumstance.

    All the best,
    Thomas
Back to Top
DevCraft banner