umbraco to linq null object issue + solution (not really)
[InvalidCastException: Null object cannot be converted to a value type.]
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +9531832
umbraco.Linq.Core.Node.NodeDataProvider.LoadFromXml(XElement xml, T node) +1958
umbraco.Linq.Core.Node.NodeTree`1.GetEnumerator() +440
System.Linq.WhereEnumerableIterator`1.MoveNext() +63
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +217
System.Linq.<GetEnumerator>d__0.MoveNext() +96
Seems that if you have a datatype with existing nodes, then make changes to the datatype (such as adding a true/false property) it will break the umbraco to linq datacontext, throwing an error when you have code in a usercontrol instantiating the collection such as 'new MyDataContext().MyDataType.First()'.
After this the existing node data is invalid, republishing the entire site will not fix it, however going through and re-saving any Nodes that are of this doctype will fix the issue. So it looks as if when a new property for a doctype is created (or modified?) the default values for the existing node database values are not set correctly, and then this is consequently fixed on saving.
I have the same issue, but I can't manually get through all the nodes of that data type (close to 1000). Does anyone has a suggestion to my (our) problem?
Mark, I got this too and your post saved the day so thanks for that!
I "solved" the issue by going through and re-savings all the nodes individually as you suggested. Fortunately I only had a half-dozen since I'm in the process of building a news site.
umbraco to linq null object issue + solution (not really)
Seems that if you have a datatype with existing nodes, then make changes to the datatype (such as adding a true/false property) it will break the umbraco to linq datacontext, throwing an error when you have code in a usercontrol instantiating the collection such as 'new MyDataContext().MyDataType.First()'.
After this the existing node data is invalid, republishing the entire site will not fix it, however going through and re-saving any Nodes that are of this doctype will fix the issue. So it looks as if when a new property for a doctype is created (or modified?) the default values for the existing node database values are not set correctly, and then this is consequently fixed on saving.
Cheers
Mark
I have the same issue, but I can't manually get through all the nodes of that data type (close to 1000). Does anyone has a suggestion to my (our) problem?
Thanks in advance.
Mark,
I got this too and your post saved the day so thanks for that!
I "solved" the issue by going through and re-savings all the nodes individually as you suggested. Fortunately I only had a half-dozen since I'm in the process of building a news site.
Talk about a "gotcha"!
Regards,
- Brian
Hi Mark,
Thanks for solution, solved my little problem :)
Worked for me too. Just save all the nodes and it stopped erroring
is working on a reply...