Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • teus 42 posts 74 karma points
    Jul 16, 2010 @ 16:47
    teus
    0

    Empty datetime bug in Linq to Umbraco 4.5

    Problem : Empty datetime property makes it unable to load the instances with Linq

    Example:Season has a empty EndDate

     
     <season id="1110" parentID="1093" level="3" writerID="0" creatorID="0" nodeType="1086" template="0" sortOrder="1" createDate="2010-07-07T12:09:17" updateDate="2010-07-16T15:52:39" nodeName="seizoen 2010/2011" urlName="seizoen-20102011" writerName="Administrator" creatorName="Administrator" path="-1,1091,1093,1110" isDoc="">
    <startDate>2010-07-16T00:00:00</startDate>
    <endDate />
    <umbracoSearchHide>0</umbracoSearchHide>
    </season>

    Then running the code

     ctx = new MyUmbracoDataContext();

                var shows = (from sh in ctx.Seasons
                              select sh ).ToList();

     leads to the errror below. Filling the enddate an publishing solves the problem but this would mean that all dates would need to be mandatory . Hope this is enough info ;-)  Regards Teus

    Server Error in '/' Application.


    String was not recognized as a valid DateTime.

    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.FormatException: String was not recognized as a valid DateTime.

    Source Error:

    Line 17:             ctx = new MyUmbracoDataContext();
    Line 18:
    Line 19: var seasons = (from sh in ctx.Seasons
    Line 20: select sh ).ToList();
    Line 21: RPshows.DataSource = shows;


    Source File: C:\SVN_WORK\StadsschouwburgVelsen_2010Website\Solution\BO.Velsen.Umbraco\usercontrols\HomePageShowViewer.ascx.cs    Line: 19

    Stack Trace:

    [FormatException: String was not recognized as a valid DateTime.]
    System.DateTime.Parse(String s, IFormatProvider provider) +6365762
    System.Convert.ToDateTime(String value, IFormatProvider provider) +14
    System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +12813387
    System.Convert.ChangeType(Object value, Type conversionType) +133
    umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml(XElement xml, T node) +3162
    umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator() +1058
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +107
    System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +472
    System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
    BO.Velsen.Umbraco.usercontrols.HomePageShowViewer.Page_Load(Object sender, EventArgs e) in C:\SVN_WORK\StadsschouwburgVelsen_2010Website\Solution\BO.Velsen.Umbraco\usercontrols\HomePageShowViewer.ascx.cs:19
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
    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.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048



    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 18, 2010 @ 10:39
    Aaron Powell
    0

    Can you log this on codeplex as a bug

  • teus 42 posts 74 karma points
    Aug 16, 2010 @ 11:14
  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 18, 2010 @ 10:29
    Aaron Powell
    0

    I'm working on a resolution for this, see this thread: http://our.umbraco.org/forum/core/41-feedback/11237-LINQ-to-Umbraco-optional-structs

Please Sign in or register to post replies

Write your reply to:

Draft