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
While trying to pass in a set of models/entities to be deleted using the DeleteAll<T>(T entities, ...) method we recieve a System.InvalidOperationException exception is thrown.
This is reproducible in our integration test whereby we create two new records using mock data and use RepoDb to Insert hte data, and populate the Identity ID values immediately. This works perfectly as expected.
Then after validating in the test, we attempt to clean up the data by deleting those very same models using the DeleteAll() method passing in the entities themselves. The expected behavior is that RepoDb would recognize the models, correctly resolve the primary Key, and then use that to explicitly delete those records only from the database without any exceptions being thrown.
Our models have Identity ID values that are part of a base model class of which all Models inherit from. When using a flat model it works, but when using a Model that inherits from our base class it fails:
Exception Message:
System.InvalidOperationExceptionHResult=0x80131509Message=The declaring type of the property is not equal to the target entity type.
Source=RepoDb
StackTrace:
at RepoDb.ClassExpression.GetPropertyValuesCache`2.Guard(ClassPropertyproperty)
at RepoDb.ClassExpression.GetPropertyValuesCache`2.<Do>d__3.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1source)
at RepoDb.Extensions.EnumerableExtension.AsList[T](IEnumerable`1value)
at RepoDb.DbConnectionExtension.DeleteAll[TEntity](IDbConnectionconnection, IEnumerable`1entities,Stringhints, Nullable`1commandTimeout,IDbTransactiontransaction,ITracetrace,IStatementBuilderstatementBuilder)
at RepoDb.Fix.StarterKit.Repositories.TesterRepository.DeleteAll(IEnumerable`1entities)in D:\Develop\GitHub.OpenSource\RepoDB\Issue991-RefactoredToFailAsExpected\RepoDb.Fix.StarterKit\Repositories\TesterRepository.cs:line 116
at Program.<Main>$(String[]args)in D:\Develop\GitHub.OpenSource\RepoDB\Issue991-RefactoredToFailAsExpected\RepoDb.Fix.StarterKit\Program.cs:line 49
Schema and Model:
Please share to us the schema of the table (not actual) that could help us replicate the issue if necessary.
CREATETABLE[dbo].[EnumTable]([Id][int]IDENTITY(1,1) NOT NULL,[StringValue][nvarchar](64) NULL,[IntValue][int]NULL)ON[PRIMARY]GO
And also the model that corresponds the schema.
namespaceRepoDb.Fix.StarterKit.Models{publicclassEntityModel:BaseEntityIdModel{publicstringStringValue{get;set;}publicLinkTypeIntValue{get;set;}}publicclassBaseEntityIdModel{//BBernard: In our Model design we have a base class with common shared properties (actually multiple levels deep) but otherwise these are merely DTO Entity Models![Identity]publicintId{get;set;}}}
Library Version:
Example: RepoDb v1.12.10-beta4 and RepoDb.SqlServer v1.1.5-beta4
The text was updated successfully, but these errors were encountered:
Bug Description
While trying to pass in a set of models/entities to be deleted using the
DeleteAll<T>(T entities, ...)
method we recieve aSystem.InvalidOperationException
exception is thrown.This is reproducible in our integration test whereby we create two new records using mock data and use RepoDb to Insert hte data, and populate the Identity ID values immediately. This works perfectly as expected.
Then after validating in the test, we attempt to clean up the data by deleting those very same models using the
DeleteAll()
method passing in the entities themselves. The expected behavior is that RepoDb would recognize the models, correctly resolve the primary Key, and then use that to explicitly delete those records only from the database without any exceptions being thrown.Our models have Identity ID values that are part of a base model class of which all Models inherit from. When using a flat model it works, but when using a Model that inherits from our base class it fails:
Exception Message:
Schema and Model:
Please share to us the schema of the table (not actual) that could help us replicate the issue if necessary.
And also the model that corresponds the schema.
Library Version:
Example: RepoDb v1.12.10-beta4 and RepoDb.SqlServer v1.1.5-beta4
The text was updated successfully, but these errors were encountered: