-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bulk Delete() over an EntitySet<T> with heterogeneous causes ReferentialConstraintViolation #292
Comments
Hello @ondrejtucny. Currently, Bulk operations does not support hierarchies that contains more than one type represented in from of table. This is mostly because DELETE statement is for content of one table and this extension keeps it very simple. I believe there are clever ways to perform such operations, but it will no longer be 1 statement and if it is not than it can be performed partially due to some errors. Then, it is time-consuming task to develop. [HierarchyRoot]
public class Root : Entity
{
[Field, Key]
public long Id { get; private set; }
[Field]
public DateTime CreationDate { get; set; }
[Field]
public string Name { get; set; }
}
public class Middle : Root
{
[Field]
public string Description { get; set; }
[Field]
public double SomeCoefficient {get; set; }
}
public class Leaf : Middle
{
[Field]
public int PriorityIndex{ get; set; }
[Field]
public string PriorityIndexName { get; set; }
} Depending on the Hierarchy's inheritance schema, fields will be spread differently. Lets take the default inheritance schema - ClassTable, and see what happens. In this mode corresponding tables contains fields of PR and the fields that was declared in the type the table represents. Say the query to delete rows looks like In general case we would work with thousands or millions of rows so possibly we would need a temporary buffer for millions of PK values. Temporary tables might work as a buffer storage but not all of RDBMSs have this feature, so we would need to load PKs to a local collection or deny the operation. Ok, what about transactions? this is another condition we need to take into account. What if another transaction changed the CreationDate of a row that out of our selection to a value that fits the condition in the query above between SELECT and final DELETE statement? A row within our selection of PKs could also change CreationDate value and became out of selection so we would false-delete data. What if a row with matching value were inserted? This is only three entities in linear hierarchy structure, and it raised so many problems to solve, some of them may be unsolvable, tree-like hierarchies will make it even more complicated. This is a lot of time for development. Unfortunately, I have limited time to spend on tasks, so this is not my priority right now to make BulkOperations support multi-table operations. |
The bulk Delete() method fails when deleting members of an EntitySet which contains ancestors of T:
This is the unit test to reproduce the issue:
The text was updated successfully, but these errors were encountered: