Someone says yes, others say no. The answer is that both answers are true, it depends on the preconditions.
Let's start from this article which explains just a little bit how the ContentDB works.
So, let's create a custom list named "Another custom list" and let's populate it with a bunch of items.
Yeah just 3 |
At first let's look at the list id, and we can find it with just a select on the AllLists table querying by title.
Aggiungi didascalia |
Remember something? |
So this is what happens behind the scenes
|
You can see that every item is serialized in xml, and surpise surprise there is an attribute called IntId, so let's see what happens importing this cmp file in another site collection:
Import-SPWeb http://sp2013 -Path "C:\TEMP\anothercustomlist.cmp" -IncludeUserSecurity -UpdateVersions Overwriteand the result is that i've now a new list with a new id, but same informations in the AllListAux and AllUserData.
Only GUIDs changed in the import |
and only GUIDs |
But what if i try to reimport? Well, items are not overwritten and i can see that same object are replicated with different list item id which starts from the value in the aux table.
So the answer is no if you are importing in a preexisting list with other items, because you never know what could be the next item id.
Below you can find some code i used to do a final test in order to get a lot of item from a list with more than 6000 items (which is not the one of this example) from the source list and the destination one, in order to do a final compare which led me to understand that Import-SPWeb is something good :)
string siteUrl = "http://sp2013/sites/test"; string listTitle = "Test"; string user = "Administrator"; string domain = "DEV"; string password = "Password"; using (ClientContext clientContext = new ClientContext(siteUrl)) { clientContext.Credentials = new NetworkCredential(user, password, domain); List list = clientContext.Web.Lists.GetByTitle(listTitle); clientContext.Load(list); clientContext.ExecuteQuery(); ListItemCollectionPosition itemPosition = null; while (true) { CamlQuery camlQuery = new CamlQuery(); camlQuery.ListItemCollectionPosition = itemPosition; camlQuery.ViewXml = @""; ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(listItems); clientContext.ExecuteQuery(); itemPosition = listItems.ListItemCollectionPosition; foreach (ListItem listItem in listItems) { Console.WriteLine("Item Title: {0}", listItem["Title"]); } if (itemPosition == null) break; Console.WriteLine(itemPosition.PagingInfo); Console.WriteLine(); } } 1000
0 commenti:
Post a Comment
Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).