Copied to clipboard

Flag this post as spam?

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


  • kristian schneider 190 posts 351 karma points
    Nov 16, 2011 @ 12:04
    kristian schneider
    0

    Creating nodes with linq2umbraco not possible?

    Hi I have the following snippet:

     var course = new Backend.DomainModel.UmbracoObjects.Course();
                course.CourseStart = DateTime.Parse(courseStart.Text);
                course.CourseEnd = DateTime.Parse(courseEnd.Text);
                course.Recurrence = repeatDropdown.SelectedValue;
                course.CourseValuePerHour = int.Parse(courseValueTextbox.Text);
                course.MaxCapacity = int.Parse(capacityTextbox.Text);
                course.Location = location.Text;
                course.CourseColor = "#" + courseColorTextbox.Text;
    
                using (var ctx = new Backend.DomainModel.UmbracoObjects.WilshireUmbracoContextDataContext())
                {
                    var coursesNode = (from c in ctx.Coursess select c).Single();
                    coursesNode.CoursesChildren.InsertOnSubmit(course);
    
                }

    When I insert into the parrentnode I get the following: 

    The NodeAssociationTree does not support Inserting items

    So is it not possible to write nodes with lin2umbraco?

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Nov 16, 2011 @ 12:10
    Jeroen Breuer
    0

    Linq2Umbraco is only used to read data and uses the NodeFactory. If you want to create data you can do that with the Document object, but Linq2Umbraco does not support this.

    There have been some experiments with creating nodes with Linq2Umbraco, but I don't know if they where ever released: http://www.aaron-powell.com/documentdataprovider-overview.

    Jeroen

  • kristian schneider 190 posts 351 karma points
    Nov 16, 2011 @ 12:26
    kristian schneider
    0

    Meh.. I guess thats not the answer I was hoping for. I'll create it oldschool way instead then

Please Sign in or register to post replies

Write your reply to:

Draft