views:

340

answers:

1

Hello, I am trying to use the new LINQ notation to add an item into a folder. I can add the item to the root of the list with:

dataContext.MyList.InsertOnSubmit(mynewObject);

But I can't find a way to make it go inside a folder. I am trying to avoid instanciating SPWeb, or SPSite objects.

Thanks, Itay,

+1  A: 

What you need to do is use the Path property on the mynewObject. This property is present if you use SPMetal to generate the Linq classes.

I created a folder in my List called Folder1, and then I set the Path property like so:

mynewObject.Path = "/Lists/MyList/Folder1";

Then call the InsertOnSubmit method as usual and your item will be in the right folder! I am not yet sure how to create the folder through linq, and do note that exceptions are thrown if the folder is not there.

Joe Capka