New Error with 411.2

Thread is closed for posting
4 posts, 0 answers
  1. Steve
    Steve avatar
    1886 posts
    Member since:
    Dec 2008

    Posted 20 Apr 2011 Link to this post

    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();
  2. Steve
    Steve avatar
    1886 posts
    Member since:
    Dec 2008

    Posted 20 Apr 2011 Link to this post

    Here's a video (changed the query a bit)

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

  3. Steve
    Steve avatar
    1886 posts
    Member since:
    Dec 2008

    Posted 20 Apr 2011 Link to this post

    ...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
                                });
  4. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 20 Jun 2011 Link to this post

    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.
Back to Top