You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Batch request on different items with same id cause "PnP.Core.ClientException: This model instance was deleted" - Consolidation not precise enough
#1581
Open
1 task done
GrubenPete opened this issue
Nov 22, 2024
· 0 comments
While requesting same properties for list items with same id of different lists in the same batch request, consolidation marks those items as deleted causing ClientException:
PnP.Core.ClientError
PnP.Core.ClientException: This model instance was deleted, you can't use it anymore
at PnP.Core.Model.TransientObject.CheckDeleted()
at PnP.Core.Model.TransientObject.GetValue[T](String propertyName)
at PnP.Core.Model.SharePoint.ListItem.get_Id()
at InvokeStub_ListItem.get_Id(Object, Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
at System.Reflection.PropertyInfo.GetValue(Object obj)
at PnP.Core.Services.BatchClient.ExecuteBatch(Batch batch)
at PnP.Core.Services.PnPContext.ExecuteAsync(Batch batch, Boolean throwOnError)
Steps to reproduce
You need 2 Lists each containing an item with the same id (not unique id).
varbatch=_pnpContext.NewBatch();await_pnpContext.Web.Lists.LoadBatchAsync(batch, list =>list.Id, list =>list.Items.QueryProperties(item =>item.Id);foreach(varlistin_pnpContext.Web.Lists.AsRequested()){foreach(variteminlist.Items.AsRequested()){awaititem.LoadBatchAsync(batch, li =>li.Id, li =>li.UniqueId);}}
so those items are wrongly merged although they are different items.
Expected behavior
Either document this behavior -> We can not reliable request items of different Lists in the same batch request.
Or use UniqueId as KeyField where possible. BatchClient.cs#L2583
Category
Describe the bug
While requesting same properties for list items with same id of different lists in the same batch request, consolidation marks those items as deleted causing ClientException:
Steps to reproduce
You need 2 Lists each containing an item with the same id (not unique id).
resulting both items in same consolidation list:
so those items are wrongly merged although they are different items.
Expected behavior
Either document this behavior -> We can not reliable request items of different Lists in the same batch request.
Or use UniqueId as KeyField where possible. BatchClient.cs#L2583
Environment details (development & target environment)
SDK version: 1.14.0
OS: Windows 11
SDK used in: ASP.NET Core Web API
Framework: .Net 8
Tooling: Visual Studio 2022
Additional context
The text was updated successfully, but these errors were encountered: