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
c.SetOutputIdentity = true; c.UpdateByProperties = new List { nameof(Item2.StringProperty), nameof(Item2.Name) }; c.PreserveInsertOrder = true; c.SetOutputNonIdentityColumns = false;
the insert or update works, but then the library throws on setting the output indentity. See example:
[Fact]publicvoidBulkInsertOrUpdate_WithOutputIdentity_FailsWhenSetOnlyIdentity(){usingvardb=GetTestContext();varnewItem=newItem2(){StringProperty="newItem",GuidProperty=newGuid("9f71ff93-2326-44d3-acb6-95b5d0566d68"),Name="newName",};varensureList=new[]{newItem,};// Bug in library causes null reference in case of BulkInsertUpdate with:// OutputIdentity == true && SetOutputNonIdentityColumns == falsevarexception=Assert.ThrowsAny<NullReferenceException>(()=>db.BulkInsertOrUpdate(ensureList,
c =>{c.SetOutputIdentity=true;c.UpdateByProperties=newList<string>{nameof(Item2.StringProperty),nameof(Item2.Name)};c.PreserveInsertOrder=true;c.SetOutputNonIdentityColumns=false;}));// Exception comes from place of the bug:Assert.Contains("EFCore.BulkExtensions.TableInfo.UpdateEntitiesIdentity",exception.StackTrace);varfromDb=db.Items2.SingleOrDefault(x =>x.GuidProperty==newItem.GuidProperty);Assert.NotNull(fromDb);// Item was inserted!}
Treats objects from output table as full entities (Item, User etc) instead of just ids (long, int - because of SetOutputNonIdentityColumns=false).
Proposed solution(s):
Add post validation of bulk config and forbid this combination of settings.
Fix the code in TableInfo.cs. This is more complicated as it would mean to rely on the order of the output table (instead of dictionary with custom primary key as it is done now). But I can do it. Is there any reason why you do not rely on the order of the output table (and use the dictionary)?
I will happily add PR with nice tests if you agree, since we already do something simmilar in our fork.
The text was updated successfully, but these errors were encountered:
tracking issue for:]
https://github.com/borisdj/EFCore.BulkExtensions/issues/1250
copy of the issue:
The text was updated successfully, but these errors were encountered: