Copied to clipboard

Flag this post as spam?

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


  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 22:32
    Dean
    0

    Linq to Umbraco Issue with Dates V4.5.2

    Hello,

    This is my first attempt to use linq to umbraco and I have stumbled across an issue that seems to be similar to this scenario that slace was fixing for v4.5.2.

    I have a Settings docType with an optional DateTime property. I create a content node of this docType and set the value, so it isn't null.

    When I query against this doctype using linqtoumbraco i get a runtime error saying that "input string was not in a correct format"

    Stack Trace

    [FormatException: Input string was not in a correct format.]
       System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +9594283
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
       System.String.System.IConvertible.ToInt32(IFormatProvider provider) +46
       System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +385
       System.Convert.ChangeType(Object value, Type conversionType) +32
       umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml(XElement xml, T node) +2369
       umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator() +713
       System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +63
       System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4178557
       WesternSprings.Website.Components.UmbracoData.SiteSettings.Get(LinqToUmbracoDataContext context) in C:\Users\Dean\documents\visual studio 2010\Projects\WesternSprings\Website\Components\UmbracoData\SiteSettings.cs:15
       WesternSprings.Website.usercontrols.Dev.NextRaceDetail.OnInit(EventArgs e) in C:\Users\Dean\documents\visual studio 2010\Projects\WesternSprings\Website\usercontrols\Dev\NextRaceDetail.ascx.cs:20
       System.Web.UI.Control.InitRecursive(Control namingContainer) +140
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Control.InitRecursive(Control namingContainer) +311
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +480

    I have checked the UmbracoDataContext and the type of this property is DateTime? which is what I expect.

    I'm using the default constructor/providers etc.

    The settings content node is an additional root node (maybe that is a problem?)

    Has anybody come across this issue and know how I can fix it?

    Cheers

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 23:11
    Aaron Powell
    0

    What's the value in the XML for the date?

  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 23:14
    Dean
    0

    Hello slace. Thanks for your reply!

    I'm not sure how to find that. But will attempt to get that info for you now.

    This is really fantastic that you help so quickly thanks.

  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 23:16
    Dean
    0

    Is this what you are after?

    <nextRaceDate>2010-10-28T00:00:00</nextRaceDate>

  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 23:17
    Dean
    0

    Maybe this is a culture issue? I haven't really dealt with cultures but i'm in New Zealand.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 23:18
    Aaron Powell
    0

    Whoops, just looked at the stack trace again, it's not a date that's causing a problem, it's a number.

    Is there any property on the document type which is a number, particularly one which isn't mandatory?

  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 23:30
    Dean
    0

    Ok so,

    No numbers, but there is a single select dropdownlist that isn't mandatory. I have set some prevalues for it that have a database type of Integer:

    The options are ("Text", "Value"): (Cancelled, 6), (Pending, 7), (On, 8)

    If this is the issue, I can just as easily make this a text dataType if that helps at the moment.

  • Dean 55 posts 98 karma points
    Oct 27, 2010 @ 23:31
    Dean
    0

    The contentxml for this field is: <nextRaceStatus><![CDATA[On]]></nextRaceStatus>

     

  • Dean 55 posts 98 karma points
    Oct 28, 2010 @ 00:17
    Dean
    0

    Hi slace,

    I have removed the dropdownlist datatype and the linq query against that doctype now works. I've just made the field a text string which isn't the nicest solution but it will do for now.

    Thanks for you help, hopefully me bringing this up will help in the future. Please let me know when there is a fix.

    Thanks again for your help, much appreciated!

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 28, 2010 @ 00:45
    Aaron Powell
    0

    If the data type puts a string into the XML but allows you to store an integer in the database there's nothing that can be done. LINQ to Umbraco's code generator isn't able to work that one out.

  • Dean 55 posts 98 karma points
    Oct 28, 2010 @ 00:46
    Dean
    0

    ok thanks slace

Please Sign in or register to post replies

Write your reply to:

Draft