This question is locked. New answers and comments are not allowed.
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
0
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.
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=neutral, PublicKeyToken=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
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.
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?
2. Can you supply a work around?
0
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.
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
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.
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
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.
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)
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?
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.
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
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.
All the best,
Thomas
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