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?
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.
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.
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
What's the value in the XML for the date?
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.
Is this what you are after?
<nextRaceDate>2010-10-28T00:00:00</nextRaceDate>
Maybe this is a culture issue? I haven't really dealt with cultures but i'm in New Zealand.
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?
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.
The contentxml for this field is: <nextRaceStatus><![CDATA[On]]></nextRaceStatus>
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!
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.
ok thanks slace
is working on a reply...