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

New Error with 411.2

3 Answers 53 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.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 20 Apr 2011, 06:42 PM
After the update I have some pages crashing with the following error

Server Error in '/' Application.

Invalid cast from 'System.String' to 'System.Guid'.

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: System.InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.

Source Error:

Line 102:
Line 103:    protected void rotationGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e) {
Line 104:            var requests = (from r in RTOHelper.RTOScope.Extent<ProgramRotationHospital>()
Line 105:                            where r.ProgramID == this.ProgramID
Line 106:                            orderby r.Rotation.RotationName

Source File: d:\websites\ca\medportal\postgrad\Apps\RTO\Admin\ProgramConfig.aspx.cs    Line: 104

Stack Trace:

[InvalidCastException: Invalid cast from 'System.String' to 'System.Guid'.]
   System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) +12556446
   System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +12813919
   System.Convert.ChangeType(Object value, Type conversionType) +133
   Telerik.OpenAccess.Query.NullableConverter`1.Convert(ResultData& data) +1003
   Telerik.OpenAccess.Query.ObjectConstructor.Convert(ResultData& data) +102
   Telerik.OpenAccess.Query.TypedEnumerator`1.ObtainCurrent() +267
   Telerik.OpenAccess.Query.TypedEnumerator`1.System.Collections.Generic.IEnumerator<T>.get_Current() +24
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +431
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
   Apps_RTO_Admin_ProgramConfig.rotationGrid_NeedDataSource(Object source, GridNeedDataSourceEventArgs e) in d:\websites\ca\medportal\postgrad\Apps\RTO\Admin\ProgramConfig.aspx.cs:104
   Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e) +191
   Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +109
   Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +254
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048


And here is the Query
var requests = (from r in RTOHelper.RTOScope.Extent<ProgramRotationHospital>()
                            where r.ProgramID == this.ProgramID
                            orderby r.Rotation.RotationName
                            select new {
                                ID = r.Id,
                                RotationName = r.Rotation.RotationName,
                                HospitalName = r.Hospital.HospitalName,
                                HospitalID = r.HospitalID,
                                RotationID = r.RotationID,
                                ProgramID = r.ProgramID,
                                ChainID = r.ChainID,
                                AllowChange = r.AllowChange
                            }).ToList();

3 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 20 Apr 2011, 06:48 PM
Here's a video (changed the query a bit)

http://screencast.com/t/16OzyL3J7

0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 20 Apr 2011, 06:51 PM
...and this fixed it

var flat = (from r in requests
                            select new {
                                ID = r.Id,
                                RotationName = (r.Rotation == null) ? String.Empty : r.Rotation.RotationName,
                                HospitalName = (r.Hospital == null) ? String.Empty : r.Hospital.HospitalName,
                                HospitalID = r.HospitalID,
                                RotationID = r.RotationID,
                                ProgramID = r.ProgramID,
                                ChainID = r.ChainID,
                                AllowChange = r.AllowChange
                            });
0
Thomas
Telerik team
answered on 20 Jun 2011, 03:20 PM
Hi Steve,

the LINQ projection code has been greatly improved for the Q2 2011 release and the issue does not exist any more. Projections are faster now too!

Best wishes,
Thomas
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
Tags
General Discussions
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Thomas
Telerik team
Share this question
or