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

Databind r.a.d.grid

13 Answers 203 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hessner
Top achievements
Rank 2
Hessner asked on 07 Feb 2009, 01:04 PM
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?

13 Answers, 1 is accepted

Sort by
0
Dimitar Kapitanov
Telerik team
answered on 08 Feb 2009, 08:55 AM
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.
0
Hessner
Top achievements
Rank 2
answered on 08 Feb 2009, 11:54 AM
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  
 
0
Hessner
Top achievements
Rank 2
answered on 09 Feb 2009, 03:03 PM
Should I open a support ticket regarding this issue?
0
Thomas
Telerik team
answered on 09 Feb 2009, 03:53 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 09 Feb 2009, 05:51 PM
1. When will next release be?
2. Can you supply a work around?
0
Thomas
Telerik team
answered on 09 Feb 2009, 06:16 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 11 Feb 2009, 04:00 PM
I will replace OpenAcces in this query,- do you have any more information regarding the next fix-date?
0
Accepted
Jan Blessenohl
Telerik team
answered on 13 Feb 2009, 02:31 PM
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.
0
Hessner
Top achievements
Rank 2
answered on 21 Feb 2009, 05:48 PM
Any chance for a patch this weekend?
0
Accepted
Dimitar Kapitanov
Telerik team
answered on 23 Feb 2009, 01:24 PM
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.
0
Sathish
Top achievements
Rank 1
answered on 27 Feb 2009, 03:38 PM
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?
0
Hessner
Top achievements
Rank 2
answered on 27 Feb 2009, 05:13 PM
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.



0
Thomas
Telerik team
answered on 27 Feb 2009, 09:04 PM
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
Tags
Development (API, general questions)
Asked by
Hessner
Top achievements
Rank 2
Answers by
Dimitar Kapitanov
Telerik team
Hessner
Top achievements
Rank 2
Thomas
Telerik team
Jan Blessenohl
Telerik team
Sathish
Top achievements
Rank 1
Share this question
or